Archived

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

Metrics info about each other services in IceBox

Hi, all! I use IceGrid
and my Client retrieve info about all metrics from all active servers:


When IceBox is active, I can retrieve info about IceBox, but how retrieve info metrics about each active services in IceBox?

Now for example I get info:
Simpe-server1: all info about metric (Connection,Threads, etc.)
...
Services(<--my IceBox):all info about metric (Connection,Threads, etc.)


?? How get info metrics from each active services(metric info about child of ICeBox)?


Im try found IceBox Api, but is nothing. Maximum IceBox Admin give me opportunity such as stop, start, using observer, if you have name of services(how its get, i am not know) Each service have info about metrics and ICeGrid Graphic Tool know how retrieve its.
please Help me!

Config xml for IceGrid:
<icegrid>

<application name="Simple">

<server-template id="Simple Server">
<parameter name="index"/>
<server id="Simple Server-${index}" exe="./server.exe" activation="on-demand">
<adapter name="Observer" endpoints="tcp -h localhost" replica- group="ReplicatedObserverAdapter"/>
<property name="Identity" value="observer"/>

<property name="IceMX.Metrics.Debug.GroupBy" value="operation"/>
<property name="IceMX.Metrics.Debug.Disabled" value="0"/>
<property name="IceMX.Metrics.Debug1.GroupBy" value="id"/>
<property name="IceMX.Metrics.Debug1.Disabled" value="0"/>
<property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/>
<property name="IceMX.Metrics.ByParent.Disabled" value="0"/>
</server>
</server-template>

<service-template id="Services">
<parameter name ="name"/>
<service name="${name}" entry="services.dll:ServiceImageI">
<property name="Hello.Identity" value="hello"/>
<adapter name="Hello-${name}" endpoints="default" id="Hello-${name}" replica-group="ImageGroup" server-lifetime="false"/>
</service>
</service-template>

<replica-group id="ImageGroup">
<load-balancing type="round-robin" n-replicas="1"/>
<object identity="hello" type="::ManagerImage::ManagerImagee"/>
</replica-group>

<replica-group id="ReplicatedObserverAdapter">
<load-balancing type="round-robin"/>
<object identity="observer" type="::IceGrid::NodeObserver"/>
</replica-group>

<node name="node1">
<server-instance template="Simple Server" index="1"/>
<server-instance template="Simple Server" index="2"/>
<server-instance template="Simple Server" index="3"/>

<icebox id="Services" activation="on-demand" exe="iceboxnet.exe">
<service name="ServiceImage" entry="services.dll:ServiceImageI">
<adapter name="adapter" endpoints="tcp"/>
<property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/>
<property name="IceMX.Metrics.ByParent.Disabled" value="0"/>
</service>
<property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/>
<property name="IceMX.Metrics.ByParent.Disabled" value="0"/>
</icebox>
</node>

<node name="node2">
<server-instance template="Simple Server" index="4"/>
<server-instance template="Simple Server" index="5"/>
<server-instance template="Simple Server" index="6"/>
</node>

</application>

</icegrid>

Comments

  • benoit
    benoit Rennes, France
    Hi Victor,

    You need to configure metrics for the service by adding IceMX properties under the XML <service> definition, for example:
    <service-template id="Services">
      <parameter name ="name"/>
      <service name="${name}" entry="services.dll:ServiceImageI">
        <adapter name="Hello-${name}" endpoints="default" id="Hello-${name}" replica-group="ImageGroup" server-lifetime="false"/>
    
        <property name="Hello.Identity" value="hello"/>
    
       <property name="IceMX.Metrics.Debug.GroupBy" value="operation"/>
       <property name="IceMX.Metrics.Debug.Disabled" value="0"/>
       <property name="IceMX.Metrics.Debug1.GroupBy" value="id"/>
       <property name="IceMX.Metrics.Debug1.Disabled" value="0"/>
       <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/>
       <property name="IceMX.Metrics.ByParent.Disabled" value="0"/>
      </service>
    </service-template>
    

    See the C++ demo/IceGrid/icebox demo from your Ice demo distribution for an example.

    Cheers,
    Benoit.
  • Thank you, but how remote retrieve all name of active service in IceBox?
  • benoit
    benoit Rennes, France
    Could you explain what you're trying to do? Are you looking for retrieving this list programmatically?

    At present there's no Slice API to retrieve the list of active services in an IceBox server. You could maintain this list yourself however by subscribing an observer with the IceBox::ServiceManager::addObserver method. See IceBox Administration - Ice 3.5 - ZeroC in the Ice manual for more information on the service manager interface.

    Note that with IceGrid, you can retrieve the IceBox server Ice.Admin object using the IceGrid::Admin interface and the getServerAdmin method. For example:
        IceGrid.RegistryPrx = ...
        IceGrid.AdminSessionPrx session = registry.createAdminSession("user", "password");
        IceGrid.AdminPrx admin = session.getAdmin();
        Ice.ObjectPrx object = admin.getServerAdmin("myServer");
        IceBox.ServiceManagerPrx manager = Ice.ObjectPrxHelper.uncheckedCast(object, "IceBox.ServiceManager");
        ...
    

    See IceGrid and the Administrative Facility - Ice 3.5 - ZeroC for more information on this.

    Cheers,
    Benoit.
  • Thank you, I am understand.
    I try looking for how retrieve info metrics of services (programmatically) in Ice-3.5.1.zip\Ice-3.5.1\java\src\IceGridGUI\...

    Code:
    Ice.PropertiesAdminPrx propAdmin =
    Ice.PropertiesAdminPrxHelper.uncheckedCast(serverAdmin.ice_facet("IceBox.Service." + _id +
    ".Properties"));

    How in IceGridGui retrieve _id ? (id service) I not think this is with help of icebox Observer.:(
  • benoit
    benoit Rennes, France
    For IceBox servers deployed with IceGrid, I recommend to obtain the administrative object using the code shown in my previous post (create an administrative session with IceGrid and use the IceGrid::Admin interface to retrieve the administrative object for your IceBox server). I don't recommend using IceBox.ServiceManager.Endpoints which is deprecated and will be removed in the next Ice release.

    The code that you are showing is to obtain the properties admin facet for a specific service so you indeed need to know the service name to create the proxy for this facet. You don't need this to register an observer with the service manager object of an IceBox server. To register an observer, you can follow the example at this link: IceGrid and the Administrative Facility - Ice 3.5 - ZeroC in the Ice manual.

    Note that if you just want to obtain the list of services deployed with the IceBox server (not the list of active vs. inactive services), an easier option is to consult the deployment information for your IceBox server:
        IceGrid.RegistryPrx = ...
        IceGrid.AdminSessionPrx session = registry.createAdminSession("user", "password");
        IceGrid.AdminPrx admin = session.getAdmin();
    
        IceGrid.ServerInfo info = admin.getServerInfo("myIceBoxServer");
        if(info.descriptor instanceof IceGrid.IceBoxDescriptor)
        {
            List<String> serviceNames = new ArrayList<String>();
            for(ServiceInstanceDescriptor service : ((IceGrid.IceBoxDescriptor)info.descriptor).services)
            {
                  serviceNames.add(service.descriptor.name);
            }
            ...
        }
    

    You'll find more details on IceGrid descriptor types in the IceGrid Slice API - Ice 3.5 - ZeroC.

    Cheers,
    Benoit.
  • benoit wrote: »
    For IceBox servers deployed with IceGrid, I recommend to obtain the administrative object using the code shown in my previous post (create an administrative session with IceGrid and use the IceGrid::Admin interface to retrieve the administrative object for your IceBox server). I don't recommend using IceBox.ServiceManager.Endpoints which is deprecated and will be removed in the next Ice release.

    The code that you are showing is to obtain the properties admin facet for a specific service so you indeed need to know the service name to create the proxy for this facet. You don't need this to register an observer with the service manager object of an IceBox server. To register an observer, you can follow the example at this link: IceGrid and the Administrative Facility - Ice 3.5 - ZeroC in the Ice manual.

    Note that if you just want to obtain the list of services deployed with the IceBox server (not the list of active vs. inactive services), an easier option is to consult the deployment information for your IceBox server:
        IceGrid.RegistryPrx = ...
        IceGrid.AdminSessionPrx session = registry.createAdminSession("user", "password");
        IceGrid.AdminPrx admin = session.getAdmin();
    
        IceGrid.ServerInfo info = admin.getServerInfo("myIceBoxServer");
        if(info.descriptor instanceof IceGrid.IceBoxDescriptor)
        {
            List<String> serviceNames = new ArrayList<String>();
            for(ServiceInstanceDescriptor service : ((IceGrid.IceBoxDescriptor)info.descriptor).services)
            {
                  serviceNames.add(service.descriptor.name);
    
    
                  IceMX.MetricsAdminPrx metricsAdmin =
                    IceMX.MetricsAdminPrxHelper.checkedCast(adminObj.ice_facet("IceBox.Service." +service.descriptor.name + ".Metrics"));
                   if (Ping(metricsAdmin))
                   {
                       ShowMetric(metricsAdmin);
                    }
            }
            ...
        }
    

    I try use metricAdmin.ice_ping(),
      private bool Ping(IceMX.MetricsAdminPrx metricsAdmin)
            {
                try
                {
                    metricsAdmin.ice_ping();
                    return true;
                }
    
                catch (Ice.Exception)
                {
                    return false;
                }
            }
    

    but Ping(IceMX.MetricsAdminPrx metricsAdmin) return true, when service active or service not active.
    Support me something like please :)
  • benoit
    benoit Rennes, France
    Hi,

    Pinging the metrics admin Ice object won't indicate whether or not the service is started or stopped, this Ice object is "hosted" by the IceBox server so it will always be accessible as long as the IceBox server is active.

    You need to register an IceBox service observer in order to monitor which services are active and which services are inactive.

    For example:
    // Java
    
    //
    // Get a proxy on the IceGrid::Admin interface
    //
    IceGrid.RegistryPrx = ...
    IceGrid.AdminSessionPrx session = registry.createAdminSession("user", "password");
    IceGrid.AdminPrx admin = session.getAdmin();
    
    //
    // Setup the object adapter to receive callbacks from the session connection
    //
    Ice.ObjectAdapter callbackAdapter = communicator.createObjectAdapter("");
    session.ice_getConnection().setAdapter(callbackAdapter);
    
    //
    // Setup the observer Ice object and create its proxy (based on the callback template proxy).
    //
    Ice.ObjectPrx tmpl = admin.getAdminCallbackTemplate();
    Ice.Identity observerId = new Ice.Identity("observer", tmpl.ice_getIdentity().category);
    callbackAdapter.add(new IceBox.ServiceObserver()
    {
         @Override public void servicesStarted(String[] services)
         {
              // The services parameter provides the active services
         }
    
         @Override public void servicesStopped(String[] services)
         {
         }
    }, observerId);
    IceBox.ServiceObserverPrx observer = IceBox.ServiceObserverPrxHelper.uncheckedCast(tmpl.ice_getIdentity(observerId));
    
    //
    // Register the observer with the service manager
    //
    Ice.ObjectPrx object = admin.getServerAdmin("myServer");
    IceBox.ServiceManagerPrx serviceManager = Ice.ObjectPrxHelper.uncheckedCast(object, "IceBox.ServiceManager");
    serviceManager.addObserver(observer);    
    

    You can also follow the directions from the Ice manual for information on how to do this: IceGrid and the Administrative Facility - Ice 3.5 - ZeroC. The code sample in the manual is a bit more complex because of the configuration of the PublishedEndpoints property for the object adapter, this isn't strictly necessary if you only have one callback object to register.

    Cheers,
    Benoit.
  • Thank you very much!