Archived

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

asked about the possibilities of icegrid to create automaticly servers

Hi,

I would like to known, if ICE allow the creation to any server on the basis of a model.

The file xml describe our application. We have two services template and each service had an adapter. Each allocatable object of adapter had the same Type (::OSL::MSG).
The node CDT had 2 icebox server and each server Icebox had one service from a template MSGService1 and MSGService2.

Actually, if we want to run for example 10 services, we must duplicate the service template, the adapter, the server and the service.

Is it possible to create a configuration who allow to icegrid to create automaticly a service from a unique client request with a unique ID? But the services must be totally indepentdent each other.


Currently, we have this Python client code:

Loop for the research of the list of allocatable objects of the each apadapter
registry = IceGrid.RegistryPrx.checkedCast(self._communicator.stringToProxy("SYSTEAM/Registry"))
        
 try :
  session = registry.createSession("root", "racine")
  sessionAdmin = registry.createAdminSession("root", "racine")
  admin = sessionAdmin.getAdmin()
  tabappli=admin.getAllApplicationNames()
    for appli in tabappli:
      TemplateDescriptorDict=admin.getApplicationInfo(appli).descriptor.serviceTemplates
      listekeys =  TemplateDescriptorDict.keys()
      for key in listekeys:
        listAdapter = TemplateDescriptorDict[key].descriptor.adapters
        nbadapter=0
          for adapter in listAdapter:
            adapters = TemplateDescriptorDict[key].descriptor.adapters[nbadapter]
              for allocatable in adapters.allocatables:
                self.listeallocatable.append(allocatable.id.name)
                nbadapter=nbadapter+1
except:
  print "Unexpected error:", sys.exc_info()[0], sys.exc_info()[1]

Loop for the connexion:
for self.allocatable in self.listeallocatable:
  session.setAllocationTimeout(5)
  try:
   self.ObjId=session.allocateObjectById(self.communicator().stringToIdentity(self.allocatable))
self.twowayMSGIceBox = OSL.MSGPrx.checkedCast(self.ObjId)
    if self.twowayMSGIceBox!= None:
      self.KeepSession = SessionRefreshThread(registry.getSessionTimeout() / 10, session)
      self.KeepSession.start()
      break
except:
  print self.allocatable.__str__() + " Allready use"
  self.allocatable=""
  self.twowayMSGIceBox = None

Thanks

Gilles

Comments

  • benoit
    benoit Rennes, France
    Hi Gilles,

    It's not clear to me why you define 2 service templates, why not just one? To answer your question, no it's not possible to instantiate one server per client. You can however easily deploy 10 servers on your node without having to duplicate the XML configuration. For example, you could use something like the following for your application descriptor:
    <icegrid>
       <application name="MSG">
          <service-template id="MSGService">
             <parameter name="name"/>
             <service name="MSGService" entry="OSL.MSG:create">
                <adapter name="MSG" endpoints="default" id="MSG-${name}">
                   <allocatable identity="msg-${name}" type="::OSL::MSG" property="MSG.Identity"/>
                </adapter>
             </service>
          </service-template>
          <server-template id="IceBox">
             <parameter name="name"/>
             <icebox id="IceBox-${name}" activation="session" exe="iceboxd">
                <service-instance template="MSGService" name="${name}"/>
             </icebox>
          </server-template>
          <node name="CDT">
             <server-instance template="IceBox" name="1"/>
             <server-instance template="IceBox" name="2"/>
             <server-instance template="IceBox" name="3"/>
             <server-instance template="IceBox" name="4"/>
             <server-instance template="IceBox" name="5"/>
             <server-instance template="IceBox" name="6"/>
             <server-instance template="IceBox" name="7"/>
             <server-instance template="IceBox" name="8"/>
             <server-instance template="IceBox" name="9"/>
             <server-instance template="IceBox" name="10"/>
          </node>
       </application>
    </icegrid>
    

    It's also not clear to me what your python code does. It looks like it just tries to allocate an available object. Why not simply call allocateObjectByType on the client session proxy for this? For example:
    registry = IceGrid.RegistryPrx.checkedCast(self._communicator.stringToProxy("SYSTEAM/Registry"))
            
    try :
      session = registry.createSession("root", "racine")
      session.setAllocationTimeout(5)
      self.ObjId=session.allocateObjectByType("::OSL::MSG")
      self.twowayMSGIceBox = OSL.MSGPrx.checkedCast(self.ObjId)
      self.KeepSession = SessionRefreshThread(registry.getSessionTimeout() / 10, session)
      self.KeepSession.start()
    except:
      print "Unexpected error:", sys.exc_info()[0], sys.exc_info()[1]
    

    Cheers,
    Benoit.
  • Hi Benoit,

    Thanks for your answer, your solution is most simple.
    But I have a problem with your python code or with the xml file
      self.ObjId=session.allocateObjectByType("::OSL::MSG")
      self.twowayMSGIceBox = OSL.MSGPrx.checkedCast(self.ObjId)
    

    allocateObjectByType is OK
    and with checkedCast
    Unexpected error: <class 'Ice.NoEndpointException'> exception ::Ice::NoEndpointException
    {
    proxy = msg-10 -t @ MSG-10
    }

    Thanks

    Gilles
  • benoit
    benoit Rennes, France
    Hi Gilles,

    This is most likely caused by the server failing to start. Is there any errors showing up in the console where you start the icegridnode? You can try adding server activation tracing with IceGrid.Node.Trace.Activator=3 in the IceGrid node configuration file to see if it provides additional clues.

    Cheers,
    Benoit.
  • Hi Benoit

    I see a error message to the console when I execute checkedCast

    Thanks

    Gilles
  • benoit
    benoit Rennes, France
    Hi Gilles,

    Your server object adapter configuration isn't found. This is most likely because of an adapter name mismatch between your code and the deployment descriptor.

    Your server creates an adapter named "MSG-MSGService" and if you used the application descriptor above without modifications, the adapter name in the XML is "MSG".

    You need to fix your code to use the adapter name "MSG" or the descriptor to use "MSG-MSGService".

    Cheers,
    Benoit.
  • Hi Benoit,

    I resolved my problem, thank for your quick answer


    Gilles