Archived

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

IceGrid and IceStorm Example

Is there a good example or tutorial on getting IceGrid and IceStorm working together?

I am try to move my project's direct proxies over to indirect proxies. However, I am having a hard time getting IceStorm to be accessible from IceGrid.

Comments

  • matthew
    matthew NL, Canada
    Since Ice comes with an IceStorm IceGrid default deployment template it should be very simple to get this going. Take a look at issue11 of the Ice newsletter (http://www.zeroc.com/newsletter/) to see an example of how this is used -- although the relevant piece of the deployment descriptor is pretty trivial:
          <server-instance template="IceStorm" instance-name="IceStorm"/>
    

    I suggest you give the template a try and if you still have problems then please reply with more details of exactly what problem you are running into.
  • After I added that line to my application.xml and I get the following error:
    unknown server template `IceStorm'
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    When describing your IceGrid application in a XML file, you need to set the application attribute import-default-templates to true to import the templates from the IceGrid registry, e.g.:

    <application name="Test" import-default-templates="true">
    ... server, node definitions ...
    </application>

    (It's also very easy with the IceGrid Admin GUI)

    Also, you need to give your IceGrid registry the path to the default templates file. For example, in the IceGrid registry configuration file:

    IceGrid.Registry.DefaultTemplates=C:\Ice-3.2.1\config\templates.xml

    And don't forget to restart the IceGrid registry after changing any of its configuration properties.

    Best regards,
    Bernard
  • Thanks for the help. I am getting a new error:
    [ 02/04/08 12:13:37.115 Subscriber: bdrmount: topic publish failed: LocatorInfo.cpp:407: Ice::NotRegisteredException:
    no object with id `bdrmount' is registered ]

    Here is my application.xml:
    <icegrid>
    <application name="BDR" import-default-templates="true">

    <node name="localhost">
    <server id="BDRServer" exe="/usr/bright/apps/bdr_server_start.sh" activation="always" user="root">
    <adapter name="MountService" endpoints="tcp" register-process="true">
    <object identity="BDRMountService" type="::BDRMount::BDRMountService" property="Identity"/>
    </adapter>
    </server>
    </node>

    <node name="localhosticestorm">
    <server-instance template="IceStorm" instance-name="IceStorm">
    <adapter name="bdrmount" endpoints="tcp" register-process="true">
    <object identity="bdrmount" type="::BDRMountEvent::BDRMountEventReceiver" property="Identity"/>
    </adapter>
    </server-instance>
    </node>
    </application>
    </icegrid>
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    You can't create IceStorm topics through IceStorm/IceGrid configuration.

    The following:

    <server-instance template="IceStorm" instance-name="IceStorm">
    <adapter name="bdrmount" endpoints="tcp" register-process="true">
    <object identity="bdrmount" type="::BDRMountEvent::BDRMountEventReceiver" property="Identity"/>

    creates the configuration for a "bdrmount" object adapter in your IceStorm server, but since IceStorm doesn't create this adapter, it doesn't have any effect.

    You can only create IceStorm topics with icestormadmin, or programmatically (with TopicManager::create).

    In your subscriber or publisher code, when using this IceGrid-deployed IceStorm instance, you can get hold of the TopicManager by using the well-known proxy "IceStorm/TopicManager" (that's <instance-name>/TopicManager). For example in C++:

    IceStorm::TopicManagerPrx mgr = IceStorm::TopicManagerPrx::checkedCast(communicator->stringToProxy("IceStorm/TopicManager"));

    Also, don't forget to configure your subscriber and publisher to use your IceGrid deployment, with something like:
    Ice.Default.Locator=DemoIceGrid/Locator:tcp -h registryHost -p <registry client endpoints port>

    Cheers,
    Bernard
  • I had tried creating the adapters in the file and only programatically and both failed.

    Here is my server side topic code:
    IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( Ice.Application.communicator()
    .propertyToProxy( "IceStorm.TopicManager.Proxy" ) );

    IceStorm.TopicPrx topic;

    try
    {
    topic = manager.retrieve( topicName );
    }
    catch ( IceStorm.NoSuchTopic e )
    {
    topic = manager.create( topicName );
    }

    Ice.ObjectPrx publisher = topic.getPublisher();
    eventReceiverPrx = BDRMountEventReceiverPrxHelper.uncheckedCast( publisher );

    Here is a snippet from the config.grid:
    Ice.Default.Locator=BDRGrid/Locator:default -p 12000

    ...

    # Events
    IceStorm.TopicManager.Proxy=BDR/TopicManager:default -p 20000
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    Which instance name do you use for your IceGrid deployment? BDR or BDRGrid?

    You need to use this instance name as the category of your well-known proxies.

    Cheers,
    Bernard
  • I changed all of the references of BDRGrid to BDR. The config.grid is now:
    Ice.Default.Locator=BDR/Locator:default -p 12000

    ...

    # Events
    IceStorm.TopicManager.Proxy=BDR/TopicManager:default -p 20000

    I still get the same error.
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    I suspect it's just a matter of replacing:
    IceStorm.TopicManager.Proxy=BDR/TopicManager:default -p 20000

    by

    IceStorm.TopicManager.Proxy=IceStorm/TopicManager

    in your config.grid configuration file (assuming that's the file you give to your subscriber / publisher).

    I.e. for the IceStorm TopicManager, you want to use the IceStorm instance name, not the IceGrid instance name. And you want to use an indirect proxy (without addressing information).

    Cheers,
    Bernard
  • The server isn't giving errors. Now its the client/subscriber's turn.

    Here is the error:
    Ice.NoEndpointException
    proxy = "IceStorm/TopicManager -t"

    Here is the client's config:
    Ice.Default.Locator=BDR/Locator:default -h xxx.xxx.xxx.xxx -p 12000

    #Events
    IceStorm.TopicManager.Proxy=IceStorm/TopicManager

    Here is the client/subscriber code:
    IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( Ice.Application.communicator()
    .propertyToProxy( "IceStorm.TopicManager.Proxy" ) );

    IceStorm.TopicPrx topic;

    try
    {
    topic = manager.retrieve( topicName );
    }
    catch ( IceStorm.NoSuchTopic e )
    {
    try
    {
    topic = manager.create( topicName );
    }
    catch ( IceStorm.TopicExists ex )
    {
    return;
    }
    }

    java.util.Map qos = new java.util.HashMap();
    Ice.ObjectPrx subscriber = communicator.stringToProxy( topicName );

    try
    {
    topic.subscribeAndGetPublisher( qos, subscriber );
    }
    catch ( Exception e )
    {
    logger.warn( "There was an error while subscribing to an event.", e );
    return;
    }
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    This error indicates that IceGrid can't find this object.

    Since your client code and configuration looks correct, I suspect a problem on the IceGrid/IceStorm side -- that changing the IceGrid instance name broke the deployment of your BDR application.

    I recommend to do the following:
    - stop your IceGrid registry/node
    - wipe out its database directories
    - restart the IceGrid registry/node
    - deploy your BDR application (using icegridadmin)
    - verify that your IceStorm server starts properly, using icegridadmin (server start) or the IceGrid Admin GUI
    - run again your subscriber

    Cheers,
    Bernard
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    I noticed a possible issue with your XML descriptor. It's likely you have a single IceGrid registry/node deployed, with the node named "localhost".

    In your XML descriptor, you deploy IceStorm on a node named "localhosticestorm", i.e. a node that doesn't exist. You really want to deploy this IceStorm and your server on the same "localhost" node:
    <icegrid>
    <application name="BDR" import-default-templates="true">
    
    <node name="localhost">
    <server id="BDRServer" exe="/usr/bright/apps/bdr_server_start.sh" activation="always" user="root">
    <adapter name="MountService" endpoints="tcp" register-process="true">
    <object identity="BDRMountService" type="::BDRMount::BDRMountService" property="Identity"/>
    </adapter>
    </server>
    
    <server-instance template="IceStorm" instance-name="IceStorm"></server-instance>
    </node>
    </application>
    </icegrid>
    
  • Thanks again for your help.

    Things are mostly working now. However, events are not getting to remote machines.

    Here is my client config:
    Ice.Default.Locator=BDR/Locator:default -h xxx.xxx.xxx.xxx -p 12000
    Callback.Client.Endpoints=tcp:udp:ssl

    #Events
    IceStorm.TopicManager.Proxy=IceStorm/TopicManager
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    The problem is with your subscriber code, sorry for not spotting it earlier:
    java.util.Map qos = new java.util.HashMap();
    Ice.ObjectPrx subscriber = communicator.stringToProxy( topicName );
    
    try
    {
    topic.subscribeAndGetPublisher( qos, subscriber );
    }
    catch ( Exception e )
    {
    logger.warn( "There was an error while subscribing to an event.", e );
    return;
    }
    

    You need to implement and register your own object (proxy) with the topic. Here you're registering the topic proxy itself with the topic!

    This subscriber object must implement the interface that your publisher is calling on, probably BDRMountEvent::BDRMountEventReceiver.

    Cheers,
    Bernard
  • I have changed the code and I get the following error:
    IceStorm.AlreadySubscribed

    The client event code is:
    java.util.Map qos = new java.util.HashMap();

    Ice.ObjectPrx subscriber = communicator.stringToProxy( topicName );

    try
    {
    topic.subscribeAndGetPublisher( qos, subscriber );
    }
    catch ( Exception e )
    {
    logger.warn( "There was an error while subscribing to an event.", e );
    return;
    }
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    As mentioned in my previous post, you need to implement and register your own subscriber object. It's something like:
            Ice.ObjectAdapter adapter =  communicator().createObjectAdapter("Clock.Subscriber");
    
            //
            // Add a Servant for the Ice Object.
            //
            java.util.Map qos = new java.util.HashMap();
            Ice.ObjectPrx subscriber = adapter.addWithUUID(new ClockI());
    
            try
            {
                topic.subscribeAndGetPublisher(qos, subscriber);
            }
            catch(IceStorm.AlreadySubscribed e)
            {
                e.printStackTrace();
                return 1;
            }
            catch(IceStorm.BadQoS e)
            {
                e.printStackTrace();
                return 1;
            }
            adapter.activate();
    

    That's from the IceStorm/clock demo.

    Cheers,
    Bernard
  • Still no joy on the remote events.

    Here is the changed client code:
    IceStorm.TopicPrx topic;

    try
    {
    topic = manager.retrieve( topicName );
    }
    catch ( IceStorm.NoSuchTopic e )
    {
    try
    {
    topic = manager.create( topicName );
    }
    catch ( IceStorm.TopicExists ex )
    {
    return;
    }
    }

    java.util.Map qos = new java.util.HashMap();

    Ice.ObjectPrx subscriber = adapter.addWithUUID( eventObject );

    try
    {
    topic.subscribeAndGetPublisher( qos, subscriber );
    }
    catch ( Exception e )
    {
    logger.warn( "There was an error while subscribing to an event.", e );
    return;
    }

    The eventObject is an object of the correct type to get the bdrmount events.

    Also, I had all of this event code working well with direct proxies. Its the indirect proxies that have been giving me fits.
  • bernard
    bernard Jupiter, FL
    Hi Jesse,

    Did you activate your adapter in your subscriber code?

    If yes, it may be simpler to post the entire code and config for your publisher / subscriber / IceGrid deployment.

    Cheers,
    Bernard
  • That was the issue. I wasn't activating the adapter.

    Thanks again for the help.