本文整理汇总了C++中ReferencePtr类的典型用法代码示例。如果您正苦于以下问题:C++ ReferencePtr类的具体用法?C++ ReferencePtr怎么用?C++ ReferencePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReferencePtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
IceInternal::LocatorInfo::clearCache(const ReferencePtr& ref)
{
assert(ref->isIndirect());
if(!ref->isWellKnown())
{
vector<EndpointIPtr> endpoints = _table->removeAdapterEndpoints(ref->getAdapterId());
if(!endpoints.empty() && ref->getInstance()->traceLevels()->location >= 2)
{
trace("removed endpoints from locator table", ref, endpoints);
}
}
else
{
ReferencePtr r = _table->removeObjectReference(ref->getIdentity());
if(r)
{
if(!r->isIndirect())
{
if(ref->getInstance()->traceLevels()->location >= 2)
{
trace("removed endpoints from locator table", ref, r->getEndpoints());
}
}
else if(!r->isWellKnown())
{
clearCache(r);
}
}
}
}
示例2: sync
vector<EndpointIPtr>
IceInternal::LocatorInfo::Request::getEndpoints(const ReferencePtr& ref,
const ReferencePtr& wellKnownRef,
int ttl,
bool& cached)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
if(!_response || _exception.get())
{
if(wellKnownRef) // This request is to resolve the endpoints of a cached well-known object reference
{
_wellKnownRefs.push_back(wellKnownRef);
}
if(!_sent)
{
_sent = true;
sync.release();
send(); // send() might call exception() from this thread so we need to release the mutex.
sync.acquire();
}
while(!_response && !_exception.get())
{
_monitor.wait();
}
}
if(_exception.get())
{
_locatorInfo->getEndpointsException(ref, *_exception.get()); // This throws.
}
assert(_response);
vector<EndpointIPtr> endpoints;
if(_proxy)
{
ReferencePtr r = _proxy->__reference();
if(!r->isIndirect())
{
endpoints = r->getEndpoints();
}
else if(ref->isWellKnown() && !r->isWellKnown())
{
//
// We're resolving the endpoints of a well-known object and the proxy returned
// by the locator is an indirect proxy. We now need to resolve the endpoints
// of this indirect proxy.
//
return _locatorInfo->getEndpoints(r, ref, ttl, cached);
}
}
cached = false;
if(_ref->getInstance()->traceLevels()->location >= 1)
{
_locatorInfo->getEndpointsTrace(ref, endpoints, false);
}
return endpoints;
}
示例3: sync
ObjectPtr
Ice::ObjectAdapterI::findByProxy(const ObjectPrx& proxy) const
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
ReferencePtr ref = proxy->__reference();
return findFacet(ref->getIdentity(), ref->getFacet());
}
示例4: create
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
const string& facet,
const ReferencePtr& tmpl,
const string& adapterId)
{
if(ident.name.empty() && ident.category.empty())
{
return 0;
}
return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), vector<EndpointIPtr>(), adapterId, "");
}
示例5: create
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
const string& facet,
const ReferencePtr& tmpl,
const vector<EndpointIPtr>& endpoints)
{
if(ident.name.empty() && ident.category.empty())
{
return 0;
}
return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
endpoints, "", "");
}
示例6: RequestHandler
ConnectRequestHandler::ConnectRequestHandler(const ReferencePtr& ref,
const Ice::ObjectPrx& proxy,
const Handle< ::IceDelegate::Ice::Object>& delegate) :
RequestHandler(ref),
_proxy(proxy),
_delegate(delegate),
_batchAutoFlush(
ref->getInstance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0),
_initialized(false),
_flushing(false),
_batchRequestInProgress(false),
_batchRequestsSize(sizeof(requestBatchHdr)),
_batchStream(ref->getInstance().get(), Ice::currentProtocolEncoding, _batchAutoFlush),
_updateRequestHandler(false)
{
}
示例7: if
void
IceInternal::LocatorInfo::finishRequest(const ReferencePtr& ref,
const vector<ReferencePtr>& wellKnownRefs,
const Ice::ObjectPrx& proxy,
bool notRegistered)
{
if(!proxy || proxy->__reference()->isIndirect())
{
//
// Remove the cached references of well-known objects for which we tried
// to resolved the endpoints if these endpoints are empty.
//
for(vector<ReferencePtr>::const_iterator q = wellKnownRefs.begin(); q != wellKnownRefs.end(); ++q)
{
_table->removeObjectReference((*q)->getIdentity());
}
}
if(!ref->isWellKnown())
{
if(proxy && !proxy->__reference()->isIndirect()) // Cache the adapter endpoints.
{
_table->addAdapterEndpoints(ref->getAdapterId(), proxy->__reference()->getEndpoints());
}
else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache.
{
_table->removeAdapterEndpoints(ref->getAdapterId());
}
IceUtil::Mutex::Lock sync(*this);
assert(_adapterRequests.find(ref->getAdapterId()) != _adapterRequests.end());
_adapterRequests.erase(ref->getAdapterId());
}
else
{
if(proxy && !proxy->__reference()->isWellKnown()) // Cache the well-known object reference.
{
_table->addObjectReference(ref->getIdentity(), proxy->__reference());
}
else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache.
{
_table->removeObjectReference(ref->getIdentity());
}
IceUtil::Mutex::Lock sync(*this);
assert(_objectRequests.find(ref->getIdentity()) != _objectRequests.end());
_objectRequests.erase(ref->getIdentity());
}
}
示例8: RequestHandler
ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference, const Ice::ObjectPrx& proxy) :
RequestHandler(reference)
{
_connection = _reference->getConnection(_compress);
RouterInfoPtr ri = reference->getRouterInfo();
if(ri)
{
ri->addProxy(proxy);
}
}
示例9: out
void
IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref,
const vector<EndpointIPtr>& endpoints,
bool cached)
{
if(!endpoints.empty())
{
if(cached)
{
trace("found endpoints in locator table", ref, endpoints);
}
else
{
trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
}
}
else
{
Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
out << "no endpoints configured for ";
if(ref->getAdapterId().empty())
{
out << "object\n";
out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
}
else
{
out << "adapter\n";
out << "adapter = " << ref->getAdapterId();
}
}
}
示例10: if
bool
Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
//
// NOTE: it's important that isLocal() doesn't perform any blocking operations as
// it can be called for AMI invocations if the proxy has no delegate set yet.
//
ReferencePtr ref = proxy->__reference();
if(ref->isWellKnown())
{
//
// Check the active servant map to see if the well-known
// proxy is for a local object.
//
return _servantManager->hasServant(ref->getIdentity());
}
else if(ref->isIndirect())
{
//
// Proxy is local if the reference adapter id matches this
// adapter id or replica group id.
//
return ref->getAdapterId() == _id || ref->getAdapterId() == _replicaGroupId;
}
else
{
vector<EndpointIPtr> endpoints = ref->getEndpoints();
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
//
// Proxies which have at least one endpoint in common with the
// endpoints used by this object adapter are considered local.
//
for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
for(vector<IncomingConnectionFactoryPtr>::const_iterator q = _incomingConnectionFactories.begin();
q != _incomingConnectionFactories.end(); ++q)
{
if((*p)->equivalent((*q)->endpoint()))
{
return true;
}
}
for(vector<EndpointIPtr>::const_iterator r = _publishedEndpoints.begin();
r != _publishedEndpoints.end(); ++r)
{
if((*p)->equivalent(*r))
{
return true;
}
}
}
//
// Proxies which have at least one endpoint in common with the
// router's server proxy endpoints (if any), are also considered
// local.
//
if(_routerInfo && _routerInfo->getRouter() == proxy->ice_getRouter())
{
for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
for(vector<EndpointIPtr>::const_iterator r = _routerEndpoints.begin(); r != _routerEndpoints.end(); ++r)
{
if((*p)->equivalent(*r))
{
return true;
}
}
}
}
}
return false;
}
示例11: catch
bool
Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
ReferencePtr ref = proxy->__reference();
vector<EndpointIPtr>::const_iterator p;
vector<EndpointIPtr> endpoints;
IndirectReferencePtr ir = IndirectReferencePtr::dynamicCast(ref);
if(ir)
{
if(!ir->getAdapterId().empty())
{
//
// Proxy is local if the reference adapter id matches this
// adapter id or replica group id.
//
return ir->getAdapterId() == _id || ir->getAdapterId() == _replicaGroupId;
}
//
// Get Locator endpoint information for indirect references.
//
LocatorInfoPtr info = ir->getLocatorInfo();
if(info)
{
bool isCached;
try
{
endpoints = info->getEndpoints(ir, ir->getLocatorCacheTimeout(), isCached);
}
catch(const Ice::LocalException&)
{
return false;
}
}
else
{
return false;
}
}
else
{
endpoints = ref->getEndpoints();
}
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
//
// Proxies which have at least one endpoint in common with the
// endpoints used by this object adapter's incoming connection
// factories are considered local.
//
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
vector<IncomingConnectionFactoryPtr>::const_iterator q;
for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q)
{
if((*q)->equivalent(*p))
{
return true;
}
}
}
//
// Proxies which have at least one endpoint in common with the
// router's server proxy endpoints (if any), are also considered
// local.
//
if(_routerInfo && _routerInfo->getRouter() == proxy->ice_getRouter())
{
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
{
return true;
}
}
}
return false;
}
示例12: out
int
IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex,
const ReferencePtr& ref,
bool sleep,
int& cnt) const
{
TraceLevelsPtr traceLevels = _instance->traceLevels();
LoggerPtr logger = _instance->initializationData().logger;
//
// We don't retry batch requests because the exception might have caused
// the all the requests batched with the connection to be aborted and we
// want the application to be notified.
//
if(ref->getMode() == Reference::ModeBatchOneway || ref->getMode() == Reference::ModeBatchDatagram)
{
ex.ice_throw();
}
const ObjectNotExistException* one = dynamic_cast<const ObjectNotExistException*>(&ex);
if(one)
{
if(ref->getRouterInfo() && one->operation == "ice_add_proxy")
{
//
// If we have a router, an ObjectNotExistException with an
// operation name "ice_add_proxy" indicates to the client
// that the router isn't aware of the proxy (for example,
// because it was evicted by the router). In this case, we
// must *always* retry, so that the missing proxy is added
// to the router.
//
ref->getRouterInfo()->clearCache(ref);
if(traceLevels->retry >= 1)
{
Trace out(logger, traceLevels->retryCat);
out << "retrying operation call to add proxy to router\n" << ex;
}
return 0; // We must always retry, so we don't look at the retry count.
}
else if(ref->isIndirect())
{
//
// We retry ObjectNotExistException if the reference is
// indirect.
//
if(ref->isWellKnown())
{
LocatorInfoPtr li = ref->getLocatorInfo();
if(li)
{
li->clearCache(ref);
}
}
}
else
{
//
// For all other cases, we don't retry
// ObjectNotExistException.
//
ex.ice_throw();
}
}
else if(dynamic_cast<const RequestFailedException*>(&ex))
{
//
// We don't retry other *NotExistException, which are all
// derived from RequestFailedException.
//
ex.ice_throw();
}
//
// There is no point in retrying an operation that resulted in a
// MarshalException. This must have been raised locally (because
// if it happened in a server it would result in an
// UnknownLocalException instead), which means there was a problem
// in this process that will not change if we try again.
//
// The most likely cause for a MarshalException is exceeding the
// maximum message size, which is represented by the subclass
// MemoryLimitException. For example, a client can attempt to send
// a message that exceeds the maximum memory size, or accumulate
// enough batch requests without flushing that the maximum size is
// reached.
//
// This latter case is especially problematic, because if we were
// to retry a batch request after a MarshalException, we would in
// fact silently discard the accumulated requests and allow new
// batch requests to accumulate. If the subsequent batched
// requests do not exceed the maximum message size, it appears to
// the client that all of the batched requests were accepted, when
// in reality only the last few are actually sent.
//
//.........这里部分代码省略.........
示例13: sync
void
IceInternal::RouterInfo::clearCache(const ReferencePtr& ref)
{
IceUtil::Mutex::Lock sync(*this);
_identities.erase(ref->getIdentity());
}
示例14:
RequestHandler::RequestHandler(const ReferencePtr& reference) :
_reference(reference),
_response(reference->getMode() == Reference::ModeTwoway)
{
}