Exemple #1
0
ConnectionIPtr
IceInternal::DirectReference::getConnection(bool& comp) const
{
    vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
    applyOverrides(endpts);

    if(endpts.empty())
    {
        endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
    }

    ConnectionIPtr connection = createConnection(endpts, comp);

    //
    // If we have a router, set the object adapter for this router
    // (if any) to the new connection, so that callbacks from the
    // router can be received over this new connection.
    //
    if(getRouterInfo())
    {
        connection->setAdapter(getRouterInfo()->getAdapter());
    }

    assert(connection);
    return connection;
}
Exemple #2
0
ConnectionIPtr
IceInternal::IndirectReference::getConnection(bool& comp) const
{
    ConnectionIPtr connection;

    while(true)
    {
        vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
        bool cached = false;
        if(endpts.empty() && _locatorInfo)
        {
            const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
            endpts = _locatorInfo->getEndpoints(self, _locatorCacheTimeout, cached);
        }

        applyOverrides(endpts);

        try
        {
            connection = createConnection(endpts, comp);
            assert(connection);
        }
        catch(const NoEndpointException& ex)
        {
            throw ex; // No need to retry if there's no endpoints.
        }
        catch(const LocalException& ex)
        {
            if(!getRouterInfo())
            {
                assert(_locatorInfo);

                // COMPILERFIX: Braces needed to prevent BCB from causing Reference refCount from
                //              being decremented twice when loop continues.
                {
                    const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
                    _locatorInfo->clearCache(self);
                }

                if(cached)
                {
                    // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from
                    //              being decremented twice when loop continues.
                    {
                        TraceLevelsPtr traceLevels = getInstance()->traceLevels();
                        if(traceLevels->retry >= 2)
                        {
                            Trace out(getInstance()->initializationData().logger, traceLevels->retryCat);
                            out << "connection to cached endpoints failed\n"
                                << "removing endpoints from cache and trying one more time\n" << ex;
                        }
                    }
                    continue;
                }
            }

            throw;
        }

        break;
    }

    //
    // If we have a router, set the object adapter for this router
    // (if any) to the new connection, so that callbacks from the
    // router can be received over this new connection.
    //
    if(getRouterInfo())
    {
        connection->setAdapter(getRouterInfo()->getAdapter());
    }

    assert(connection);
    return connection;
}