NodeName of request

GreenhippoGreenhippo Member AlexOrganization: University of AucklandProject: Intelligent Middleware ✭✭
Hi,

Currently i have an icegrid setup with the nodes communicating with each other and im attempting to get which node each request came from.

It is possible to get the ipaddress of each request by looking at the current.con is there an easy way to lookup the nodes ip address so i can get the node name of where the request came from?

Alternativly is there a way to get the node name that an object is hosted on so that the request sender could add this additional information into the context map.

Thanks for any insight you can offer

Comments

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

    Yes, you can check for the IP address with the "current.con" attribute by parsing the string returned by the toString() method of the Ice::Connection interface. Using a context is another option.

    You could use the IceGrid node "IceGrid.Node.PropertiesOverride" property to set for example a "NodeName" property. This property would be added to the configuration file of each server hosted by the node. Your servers would use this property to set an implicit context on the communicator.

    Cheers,
    Benoit.
  • GreenhippoGreenhippo Member AlexOrganization: University of AucklandProject: Intelligent Middleware ✭✭
    Thanks for the quick reply

    Im aware you can get the ip address, the problem is i need an acutal node name so i can get load information from the registry about the caller node. so i need a way to convert the ip address to the node name

    The IceGrid.Node.PropertiesOverride seems to be a nice alternative, but cant seem to get it working, could you give me a brief example of how you set it, its not clear what you set it equals to.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    For example, you can set it with the following property value:
    IceGrid.Node.PropertiesOverride="NodeName=node1"
    


    This will add the NodeName=node1 property to the configuration file of each server deployed on the node. You could also simply set it in the deployment descriptor if you use one, for example:
    <icegrid>
      <application name="Simple">
        <node name="localhost">
          <server id="SimpleServer" exe="./server" activation="on-demand">
            <adapter name="Hello" endpoints="tcp" register-process="true">
              <object identity="hello" type="::Demo::Hello" property="Identity"/>
              <property name="NodeName" value="${node}"/>
            </adapter>
          </server>
        </node>
      </application>
    </icegrid>
    

    Cheers,
    Benoit.
Sign In or Register to comment.