Archived

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

FileParser unusable outside icegridadmin

Hi guys,

I think this is a bug.

My program has:
#include <IceGrid/FileParser.h>

When I try to link this code, I get the following linker errors:

/opt/Ice-3.2.0/include/IceGrid/FileParser.h:121: undefined reference to `vtable for IceGrid::ParseException'
In function `__tcf_14':
/opt/Ice-3.2.0/include/IceGrid/FileParser.h:140: undefined reference to `IceGrid::ParseException::~ParseException()'

even though I'm using -lIceGrid.

I had a look through the Ice Makefiles, and it looks like FileParser.cpp is only included in icegridadmin, _not_ libIceGrid. I think probably this is incorrect -- otherwise the FIleParser interface is un-useable by any program other than icegridadmin. Would you agree?


What I'm trying to do is call "IceGridAdminPrx->addApplication()" from my program. I'd like to build up an ApplicationDescriptor, using the same .xml file that icegridadmin reads. It seems like there's no easy way to do this, because FileParserI.h/cpp only get built into the icegridadmin executable, and are therefore not accessible to me. So it looks like I either have to re-write this functionality or copy the appropriate files into my source tree, is this right? I'm not super-keen on either of these options.


Thanks for the help,

Alex

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Yes, it should be included in the IceGrid library, we'll fix this. You can work-around this by translating slice/IceGrid/FileParser.ice and compiling the resulting FileParser.cpp with your project.

    Note that to use the parser, you'll need to start the icegridadmin tool with the -s option. The icegridadmin tool will run in "server" mode and will print out the proxy of the IceGrid::FileParser object that you should use to parse XML files (this is how the IceGrid Admin GUI parses XML files for example). There's no way to directly parse the XML file from your C++ application, adding support for this is on our TODO list.

    Cheers,
    Benoit.
  • Benoit,
    Note that to use the parser, you'll need to start the icegridadmin tool with the -s option. The icegridadmin tool will run in "server" mode and will print out the proxy of the IceGrid::FileParser object that you should use to parse XML files (this is how the IceGrid Admin GUI parses XML files for example).

    I'm not sure I understand this (I read the section in the Ice manual). Do you mean I should run 'icegridadmin -s' and then manually cut-and-paste the proxy it prints out for use in my application?
    How does the IceGrid Admin GUI work, since it doesn't require this? Does it fork a separate process that starts icegridadmin and capture the output? This sounds ugly...

    As a work-around, I tried just copying the following files from src/IceGrid into my source tree:
    FileParser.h/cpp
    FileParserI.h/cpp
    DescriptorParser.h/cpp
    DescriptorBuilder.h/cpp
    Util.h/cpp

    This builds OK, and by linking against IceXML I can generate my program.

    My code to start an application now looks something like this:
    IceGrid::FileParserPtr fileParser;
    fileParser = new FileParserI;
    IceGrid::ApplicationDescriptor d;
    d = fileParser->parse( xmlFileName_, iceGridAdminPrx_ );
    iceGridAdminPrx_->addApplication( d );
    

    Should this approach work? It throws an exception on the 'fileParser->parse' line:
    /opt/Ice-3.2.0/include/IceUtil/Handle.h:46: IceUtil::NullHandleException
    with no indications about why. I've double-checked that all the inputs are good. Any clues as to what might be wrong?

    Thanks again for the help,


    Alex
  • benoit
    benoit Rennes, France
    Hi,

    Yes, the IceGrid Admin GUI forks the icegridadmin utility and uses it in "server" mode to parse files. If the parser was in a remote process, you wouldn't be able to parse local files from the GUI. Using the icegridadmin utility in server mode is the only supported way right now to parse files.

    However, if you want to embed the parser code in your project, you should just include DescriptorParser.h/cpp, DescriptorBuilder.h/cpp and Util.h/cpp. Then, you can use the [noparse]DescriptorParser::parseDescriptor()[/noparse] method to parse your file (declared in DescriptorParser.h). See the implementation of Parser::addApplication in src/IceGrid/Parser.cpp for an example on how to use it.

    We'll discuss moving the IceGrid parser code in the C++ IceGrid client library or perhaps a separate library.

    Cheers,
    Benoit.
  • Thanks, this worked: I copied the files you mentioned into my source tree, and I can now parse files, add applications, etc.

    I'm also trying to patch an application. This invariably times out (throwing an exception) but continues in the background. Is there any way to block till patching is complete (or at least find out if patching is complete)? I noticed that icegridadmin v3.1 would quit with an Ice::TimeoutException (but continue patching), where icegridadmin v3.2 will not return until the application is patched. How does it do this?


    Thanks,

    Alex
  • benoit
    benoit Rennes, France
    Hi Alex,

    With Ice 3.2, the interface between the node and the registry to patch servers was changed to rely on a callback mechanism rather than just a simple invocation (which would eventually timeout if the patching takes too long).

    I'm not sure I understand your problem though. Are you calling patchApplication directly on the IceGrid::Admin interface? This call could timeout if there's a timeout set for the proxy, is there a timeout set?

    Cheers,
    Benoit.
  • With Ice 3.2, the interface between the node and the registry to patch servers was changed to rely on a callback mechanism rather than just a simple invocation (which would eventually timeout if the patching takes too long)

    Do you mean that it sets up Observers?
    Are you calling patchApplication directly on the IceGrid::Admin interface? This call could timeout if there's a timeout set for the proxy, is there a timeout set?

    Yes, exactly: I have a non-negative timeout set, so when I call adminPrx->patchApplication, it times out for any non-trivial patch.
  • benoit
    benoit Rennes, France
    The registry setups internally a callback object which is invoked by the node when the patching is done, once the patching is done this callback object is destroyed.

    The only way to avoid the timeout exception for your client is to increase the timeout setting to a value which is large enough for the patch to complete. You'll need to use the same timeout for the IceGrid::Registry, IceGrid::AdminSession and IceGrid::Admin proxies. This is required because the registry resctricts access to the session and admin objects to the connection used to create the session with the registry...

    Note that improving the patching feedback is still on our TODO list...

    Cheers,
    Benoit.
  • The registry setups internally a callback object which is invoked by the node when the patching is done, once the patching is done this callback object is destroyed.

    I don't really understand how this works, but I think I'll just stick with no feedback for now, and hope that I can improve things once you guys get further down the TODO list.

    Thanks again for all the work, this tool really makes things easier for us!