Home Help Center

How to auto remove the died adapter at ice grid registry?

JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
We use the following method to deploy our servant object to ice grid:
String perfix="CommonServer";
Properties props = Ice.Util.createProperties();
props.setProperty("Ice.Default.Locator", defaultLocator);
props.setProperty("Ice.ImplicitContext", "PerThread");
props.setProperty("Ice.ProgramName", prefix + serverId);

props.setProperty(prefix + "Adapter.ReplicaGroupId", prefix
		+ "RepGroup");
props.setProperty(prefix + "Adapter.RegisterProcess", "0");
props.setProperty(prefix + "Adapter.ThreadPool.Size", "10");
props.setProperty(prefix + "Adapter.ThreadPool.SizeMax",
		"100");
props.setProperty(prefix + "Adapter.ThreadPool.SizeWarn",
		"100");
props.setProperty(prefix + "Adapter.AdapterId", prefix
		+ serverId + "." + prefix + "Adapter");
props.setProperty(prefix + "Adapter.Endpoints", endPoints);
InitializationData id = new InitializationData();
id.properties = props;
communicator = Ice.Util.initialize(id);
adapter = communicator.createObjectAdapter(prefix+ "Adapter");
Ice.Identity objectIdentity = communicator.stringToIdentity(servant.getObjectId());
adapter.add(servant.getServantObject(), objectIdentity);
adapter.activate();
communicator.waitForShutdown();

After my program startup, I can see these Adapters at IceGridGUI.

When my program shutdown, It call the following methods to destroy or remove adapters from IceGrid registry:
adapter.deactivate();
adapter.destroy();
communicator.shutdown();
We deploy three program instances with different AdapterId at the same ReplicaGroupId, and here is a problem:
when I send kill -9 PROCESS_ID command to kill one instance of my program, it don't call the destroy method to remove adapters from ice registry. So there is a died adapter at ice registry. When PHP program trying to invoke the method of servant object, it wait for a long time to find the alive adapter from ice registry, and some times invoke fail.

So how to resolve this problem?

I want to develope a timer program to auto clear the died adapters, will anybody tell me how to?


Thanks!

Comments

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

    If you were deploying your servers on an IceGrid node, the node would automatically clear the adapter endpoints from the registry when it detects that the server is gone.

    In your case, since the server doesn't shutdown gracefully (when killed with kill -9), you'll need to manually clear the endpoints with the registry. You can do this with the IceGrid administrative facility. You can use for example the icegridadmin "adapter remove" command. To do this programatically, you'll have to use the IceGrid::Admin interface removeAdapter method. Please see the Ice manual for more information on the IceGrid administrative facility.

    Cheers,
    Benoit.
  • JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
    To do this programatically, you'll have to use the IceGrid::Admin interface removeAdapter method. Please see the Ice manual for more information on the IceGrid administrative facility.

    And there is a another problem:
    if( adapter is died){
    remove this adapter
    }
    How to assert which adapter died, or which adapter should be removed? There is not enough information at AdapterInfo for me to do.

    If you were deploying your servers on an IceGrid node, the node would automatically clear the adapter endpoints from the registry when it detects that the server is gone.
    My program instance can't startup standalone, it's deployed at an OSGi container(Equinox).
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    IceGrid can't provide you this information since it has no idea which process is hosting the object adapter and whether or not this process is still alive (it only knows this for servers started by an IceGrid node...).

    You'll have to monitor the process yourself and remove the adapter when you detect that the process is gone.

    Cheers,
    Benoit.
  • JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
    Thanks for your reply!
    You'll have to monitor the process yourself and remove the adapter when you detect that the process is gone.

    We deploy serval adapters at a container, sometimes, container is OK, but adapter inside it is not OK, it can't be invoked by php client program.

    Then in order to add adapter to ice node, we sometimes use IceGridGUI to add a virtual server to the node: set the execute path to "ls". ls is a Linux command, there is no port for ls command to listen, then we startup our container, startup our adapters, and to my surprise, I can see this virtual server node is running at IceGridGUI.

    But after it run for some days, It can't be called by php client, and when I trying to restart my container, a exception occurs, the exception message is :
    Object in used or adapter in used. Then we restart ice node, and then restart container, and then ok.



    Thanks!
  • JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
    IceGrid can't provide you this information since it has no idea which process is hosting the object adapter and whether or not this process is still alive (it only knows this for servers started by an IceGrid node...).

    I think there is another way to do:
    (1) Find the adapter by adapter id.
    (2) Trying to invoke a method of the adapter, such as ping() or ice_ping().
    (3) if this method can't be invoked or call fail, then remove it.

    Do you think is OK?

    Thanks a lot!
Sign In or Register to comment.