Results 1 to 6 of 6

Thread: automatic reconnection

  1. #1
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9

    automatic reconnection

    I'm looking for a way to automatically make clients connect to servers and continue normal operations in the event that:

    1) The client is started earlier then the server.

    2) The server is shutdown and restarted on another host while the client is calling its methods.

    This way I avoid race conditions while starting the system and will be able to kill and restart both the client and the server while still continuing normal operations. I have this working by catching exceptions and reconnecting, but now I want to hide this extra complexity so that my client and server programs remain simple, look similar to this:

    SERVER
    --------
    Ice::ObjectAdapterPtr adapter=
    communicator()->createObjectAdapterWithEndpoints("Hello", "default");

    Ice::ObjectPtr object = new HelloI;
    HelloI::setHelloProxy(communicator(),adapter,object,"hello2");
    // register to IcePack/Admin
    // On default this overwrites any existing proxies with that name

    adapter->activate();
    communicator()->waitForShutdown();


    CLIENT
    --------
    HelloPrx hello=HelloI::getHelloProxy(communicator(),"hello2");
    // retrieve from IcePack/Admin

    while(1)
    {
    hello->methodCall();
    }

    Note that the 'hello->methodCall()' is hidding the fact that it internally catches any 'Ice::ConnectionRefusedExceptions' when the server is down and will then try to reconnect using the getHelloProxy() method above with the name 'hello->ice_getIdentity().name' indefinitly.

    To hide the extra complexity I'm thinking of hiding it by changing the slice2cpp, slice2java, slice2*... code generators to generate the required code.

    Do you think this would be a good idea?

    The problem seems standard, are there any solutions available? did others ever do anything similar?

    Is there any additional documentation available on the code generators?

    Thanks you for your time,
    Bas Terwijn

  2. #2
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Ice can automatically retry for you. Please see the description of the property Ice.RetryIntervals for details, and search the Ice manual for "retry". Also have a look at the property Ice.Trace.Retry, and the "idempotent" operation modifier.

  3. #3
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9
    Thank you for your responds.

    It's working although I can not set the retry strategy to repeat indefinitly. Next time I spend more time searching the manual instead of programming it myself.

    Thanks again,
    Bas Terwijn

  4. #4
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9
    I'm looking for a way to do the following but could not find a solution in the manual.

    I want my client to retry connecting to 'someObject', as the client needs this object to function properly, but I don't want it to retry connecting to 'log' which is my logger. When the 'log' object isn't available the client should continue normal operations but without logging anything. In order to retry I have set the 'Ice.RetryIntervals' property in my config file so that it tries reconnecting every second for one minute, but now my client is also retrying its connection to the 'log' object.

    My question is, how do I make the client code below work both when the 'log' object is and isn't available?

    Maybe there is a way to set the 'Ice.RetryIntervals' property for specific connections?

    CLIENT
    ----------
    Ice::ObjectPrx base = communicator()->stringToProxy("someObject");
    objectPrx object = objectPrx::checkedCast(base);

    base = communicator()->stringToProxy("log");
    LogPrx log = LogPrx::checkedCast(base);

    while (1)
    {
    object->someMethod();
    log->log("some message");
    sleep(1);
    }
    -----------

    I hope you can help me, thank you in advance,
    Bas Terwijn

  5. #5
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    There is currently no way to set retry intervals per proxy or per connection. You can only set retry intervals per communicator. So you could create two communicators, with two different settings for Ice.RetryIntervals, and use one of them for your regular proxies, and the other for the "log" proxy.

  6. #6
    rc_hz is offline Registered User
    Name: Eric RC
    Organization: www.genband.com
    Project: No project yet
    Join Date
    Jul 2004
    Location
    Hangzhou, China
    Posts
    189
    ...There is currently no way to set retry intervals per proxy or per connection. You can only set retry intervals per communicator...
    Maybe it is better to add this feature that we can set retry intervals per proxy or per connection.
    Last edited by rc_hz; 05-31-2005 at 08:48 PM.
    Eric RC
    www.genband.com (telecommunication)
    I like ICE (Ice for C++/Java/Python)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatic UTF-8 convertation
    By xorax in forum Help Center
    Replies: 1
    Last Post: 02-26-2010, 03:27 PM
  2. replication and automatic restarting
    By Vivien Delage in forum Help Center
    Replies: 1
    Last Post: 04-16-2008, 02:53 PM
  3. Ice-E reconnection latency
    By leya in forum Help Center
    Replies: 4
    Last Post: 10-25-2007, 10:47 PM
  4. Automatic Adapter registration
    By vsonnathi in forum Help Center
    Replies: 12
    Last Post: 10-26-2004, 10:13 AM
  5. Proxy reconnection to reactivated adapter
    By brian in forum Help Center
    Replies: 4
    Last Post: 01-21-2004, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •