Archived

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

IceGrid Replication

Hello,

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):

<icegrid>

  <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"/> -->
      </server>
    </server-template>
    
		<replica-group id="ReplicatedHelloAdapter">
      <load-balancing type="ordered" n-replicas="1"/>
      <object identity="Hello" type="::Demo::Hello"/>
    </replica-group>

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

  </application>
</icegrid>


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:

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

    menu();

    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->ice_endpointSelection(Ice::Ordered);
    do
    {
        try
        {
        		hello = HelloPrx::checkedCast(ic->stringToProxy("Hello@ReplicatedHelloAdapter")->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')
            {
                hello->sayHello();
            }
            else if(c == 's')
            {
                hello->shutdown();
            }
            else if(c == 'x')
            {
                // Nothing to do
            }
            else if(c == '?')
            {
                menu();
            }
            else
            {
                cout << "unknown command `" << c << "'" << endl;
                menu();
            }
        }
        catch(const Ice::Exception& ex)
        {
            cerr << ex << endl;
        }
				//index++;
				//ic = Ice::initialize(argc, argv, "config.client");
				//hello = HelloPrx::checkedCast(seq[index&0x1]);
				//Ice::ConnectionPtr conn = hello->ice_getConnection();
				//conn->close(false);
				//hello->ice_getCachedConnection()->close(true);
        //hello->shutdown();
				//ic->destroy();
    }
    while(cin.good() && c != 'x');

    return EXIT_SUCCESS;
}

Comments

  • benoit
    benoit Rennes, France
    Hi,

    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.

    Cheers,
    Benoit.
  • Solved!

    Benoit,

    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,
    Ahmed