Home Help Center

iceGrid/simple demo with replication

prettyManprettyMan Member Rahajaniaina AndriamasinoroOrganization: université paul sabatier ToulouseProject: student research information system
Hi
I want to have all information about the replication. In the code below why seq.size() is always = 0. I used the code sample in iceGrid/simple demo with replication :
void
HelloI::sayHello(const Ice::Current& c)
{
   	Ice::CommunicatorPtr communicator = c.adapter->getCommunicator();
	IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(communicator->stringToProxy("DemoIceGrid/Query"));
	Ice::ObjectPrx proxyGroup = communicator->getDefaultLocator()->findAdapterById("ReplicatedHelloAdapter");
																					
	if(proxyGroup)
	{
		Ice::ObjectProxySeq seq = query->findAllReplicas(proxyGroup);
		if(seq.size()==0)
                    cout<<"empty"<<endl;
                else
                    cout<<"ok"<<endl;

	}
	cout << " says Hello World!" << endl;
}


I used "application_with_replication.xml" file for this.
thanks

Comments

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

    Don't use the locator findAdapterById method to get the proxy as this method returns a proxy that contains endpoints (i.e.: a direct proxy), instead simply use the following:
    Ice::ObjectPrx proxy = communicator->stringToProxy("[email protected]")
    query->findAllReplicas(proxy);
    

    Cheers,
    Benoit.
  • BenjamimBenjamim Member Benjamim MarquesOrganization: University of Beira InteriorProject: Thesis work Fault tolerance in distributed Systems
    FindAllReplicas

    Hello, I´m trying to use the same operation but i´m experiencing some trouble.
    HelloPrx hello3 = null;
    Ice.ObjectPrx proxies[]= null;
    
    IceGrid.QueryPrx query = 
            		IceGrid.QueryPrxHelper.checkedCast(communicator ().stringToProxy("DemoIceGrid/Query"));
    
    
    Ice.ObjectPrx prox = communicator().stringToProxy("[email protected]");
    
    proxies = query.findAllReplicas(prox);
    
                        int i = 0;
                            for(i = 0; i <= proxies.length; i++ ){
                           	 hello3 = null;
                           	 System.out.println("Proxie "+i+" -->"+proxies[i].toString());
                           	 hello3 = (HelloPrxHelper.checkedCast(proxies[i]));
                           	 System.out.println("HELLO3-->"+hello3.toString());
                           	 hello3.sayHello(); }
    
    


    My problem is that I´m trying to obtain all the replicas and send the message to all of them, e have successfully obtained the array of proxies but when I try to instantiate the object hello3 it doesn´t work anda get exception of object not registered.

    Can you please help me?

    why can´t I create the hello3 for each proxie?
  • BenjamimBenjamim Member Benjamim MarquesOrganization: University of Beira InteriorProject: Thesis work Fault tolerance in distributed Systems
    Benjamim wrote: »
    Hello, I´m trying to use the same operation but i´m experiencing some trouble.
    HelloPrx hello3 = null;
    Ice.ObjectPrx proxies[]= null;
    
    IceGrid.QueryPrx query = 
            		IceGrid.QueryPrxHelper.checkedCast(communicator ().stringToProxy("DemoIceGrid/Query"));
    
    
    Ice.ObjectPrx prox = communicator().stringToProxy("[email protected]");
    
    proxies = query.findAllReplicas(prox);
    
                        int i = 0;
                            for(i = 0; i <= proxies.length; i++ ){
                           	 hello3 = null;
                           	 System.out.println("Proxie "+i+" -->"+proxies[i].toString());
                           	 hello3 = (HelloPrxHelper.checkedCast(proxies[i]));
                           	 System.out.println("HELLO3-->"+hello3.toString());
                           	 hello3.sayHello(); }
    
    


    My problem is that I´m trying to obtain all the replicas and send the message to all of them, e have successfully obtained the array of proxies but when I try to instantiate the object hello3 it doesn´t work anda get exception of object not registered.

    Can you please help me?

    why can´t I create the hello3 for each proxie?

    Sorry the exception is
    Ice.ObjectNotExistException
    id.name = "hello"
    id.category = ""
    facet = ""
    operation = "ice_isA"


    the proxi obtained individualy by the demo is
    hello-1 -t @ SimpleServer-1.Hello

    when I get it from the replicas is
    hello -t @ SimpleServer-1.Hello

    can this be the reason?? for the exception?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    This exception indicates that the Ice object with the identity "hello" doesn't exist in the server. If you deployed the IceGrid/simple application with application_with_templates.xml this is expected as the descriptor configures the identity of the hello Ice object to be "hello-${index}" where ${index} is the index of the server.

    You should be using application_with_replication.xml instead. Try updating your application with:
    $ icegridadmin --Ice.Config=config.grid -e "application update application_with_replication.xml"
    

    and see if this helps.

    Cheers,
    Benoit.
  • BenjamimBenjamim Member Benjamim MarquesOrganization: University of Beira InteriorProject: Thesis work Fault tolerance in distributed Systems
    Thanks for the reply Benoit,

    I have done it but still the same problem.

    here is my xml:
    <icegrid>
    
      <application name="Simple">
    
        <server-template id="SimpleServer">
          <parameter name="index"/>
          <server id="SimpleServer-${index}" exe="java" activation="on-demand">
            <option>Server</option>
            <adapter name="Hello" endpoints="tcp" replica-group="ReplicatedHelloAdapter"/>
            <property name="Identity" value="hello"/> 
          </server>
        </server-template>
    
        <replica-group id="ReplicatedHelloAdapter">
          <load-balancing type="round-robin"/>
          <object identity="hello" type="::Demo::Hello"/>
        </replica-group>
    
    	
        <node name="node">
          <server-instance template="SimpleServer" index="1"/>
        </node>
    
    	<node name="node2">
          <server-instance template="SimpleServer" index="2"/>
        </node>
    
      </application>
    
    </icegrid>
    


    and code again:
    IceGrid.QueryPrx query = 
            		IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Query"));
    
     Ice.ObjectPrx prox = communicator().stringToProxy("[email protected]");
    
    
                 int i = 0;
                 for(i = 0; i < proxies.length; i++ ){
                	 hello3 = null;
                	 System.out.println("Proxie "+i+" -->"+proxies[i].toString());
                	 hello3 = HelloPrxHelper.checkedCast(proxies[i]);//HERE THE EXCEPTION
                	 System.out.println("HELLO3-->"+hello3.toString());
                 }
    
    

    contents of proxies[] image in atach

    Thanks in advance.
  • BenjamimBenjamim Member Benjamim MarquesOrganization: University of Beira InteriorProject: Thesis work Fault tolerance in distributed Systems
    Thanks Benoit, it works, I can´t understand why but I just turn of everithing,
    and add more trace to registry, then started again anda it works fine.



    Another question now, I want to replicate servers condition, is it easy to achive by using IceStorm or is easier if made by me.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    I assume you are looking for replicating the server state. IceStorm can be used to implement replication but it won't provide "out of the box" replication for your server state. You first have to decide how you want to implement the replication before choosing the "tools" to implement it. As a starter, I recommend to read my article in the Issue #23 of the Connections newsletter here. It presents one way to implement replication.

    Cheers,
    Benoit.
  • BenjamimBenjamim Member Benjamim MarquesOrganization: University of Beira InteriorProject: Thesis work Fault tolerance in distributed Systems
    Hi again, thanks for the help.

    I thing I have all I need, this is funcional example for case of study for my thesis, I have an idea for aplication.

    Thanks again.
Sign In or Register to comment.