Archived

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

Custom Administrative Facets

I've been using "addAdminFacet" add a custom admin facet, I know by "GetServerAdmin" can remotely access the built-in admin facet in a grid service, such as Porcess, Properties, but how to get custom facet of it, please give me some sample code

Comments

  • benoit
    benoit Rennes, France
    Hi,

    If you have the proxy of the Ice admin object from your server, getting a proxy on your custom facet is trivial:
    // Java
    Ice.ObjectPrx admin = icegridAdmin.getServerAdmin("MyServer");
    MyCustomFacetPrx facet = MyCustomFacetPrxHelper.checkedCast(admin, "MyFacet");
    

    Here "MyFacet" is the name you used to add your facet with addAdminFacet.

    Cheers,
    Benoit.
  • Hi benoit,

    Thank for your reply,I had tried the code before I post this question,but only can access built-in facet.

    I had always got "ObjectNotExistException",here is mycode
    //NodeObserver  C# ,I want to get manager facet when a node register to grid,so I can do some [FONT=Tahoma]management work,such as automatically create a room object .[/FONT]
    
     public override void updateServer(string node, ServerDynamicInfo updatedInfo, Current current__)
            {
                if (updatedInfo.state == ServerState.Active)
                {
                    try
                    {
    
                        var serverAdmin = _adminPrx.getServerAdmin(updatedInfo.id);
    
                        Console.WriteLine(null == PropertiesAdminPrxHelper.checkedCast(serverAdmin, "Properties"));    //got it
    
                        Console.WriteLine(null == RoomManagerPrxHelper.checkedCast(serverAdmin, "RoomManager"));  //this is null,and catch error below
    
    
                    }
                    catch (Ice.Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
    
    
            }
    


    Target icebox service
    communicator.addAdminFacet(new RoomManagerI(), "RoomManager");
    
    //need any other code? should I host it in my own adapter?
    


    I don't know if I missing something special or need some necessary configuration.


    Many thanks!
  • bernard
    bernard Jupiter, FL
    Hi Bo,

    This is unfortunately an unintentional limitation of IceBox: you currently can't add custom facets to the IceBox admin object.

    With IceBox, you are dealing with multiple communicators: IceBox's own communicator, which hosts the admin object, and the communicators of the services. See https://doc.zeroc.com/display/Ice36/IceBox+Administration for more details.

    Here, you're adding your "RoomManager" facet to a service communicator. By default, IceBox creates and registers built-in facets for each service, and adds them to the main IceBox's communicator admin object. IceBox does all this just after initializing the service's communicator, before you have a chance to add an additional facet.

    We currently don't provide access to the main IceBox communicator from an IceBox service, or another simple way to register custom admin facets with this communicator's admin object.

    One work-around would be to use a regular server instead of an IceBox server with services. Another option would be to write an Ice plug-in for IceBox: this plug-in could then provide access to the IceBox communicator to your IceBox services.

    Cheers,
    Bernard
  • Finally I use a regular server instead,successfully solved the problem.

    Thanks for helping me so much!


    Best wishes!