本文整理汇总了C++中ice::ObjectProxySeq类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectProxySeq类的具体用法?C++ ObjectProxySeq怎么用?C++ ObjectProxySeq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectProxySeq类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool
IceInternal::RouterInfo::addProxy(const Ice::ObjectPrx& proxy, const AddProxyCallbackPtr& callback)
{
assert(proxy);
{
IceUtil::Mutex::Lock sync(*this);
if(_identities.find(proxy->ice_getIdentity()) != _identities.end())
{
//
// Only add the proxy to the router if it's not already in our local map.
//
return true;
}
}
Ice::ObjectProxySeq proxies;
proxies.push_back(proxy);
AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy);
_router->begin_addProxies(proxies,
newCallback_Router_addProxies(this,
&RouterInfo::addProxyResponse,
&RouterInfo::addProxyException),
cookie);
return false;
}
示例2:
InternalRegistryPrxSeq
InternalRegistryI::getReplicas(const Ice::Current&) const
{
InternalRegistryPrxSeq replicas;
Ice::ObjectProxySeq proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
return replicas;
}
示例3: ObjectProxySeq
Ice::ObjectProxySeq
QueryI::findAllReplicas(const Ice::ObjectPrx& proxy, const Ice::Current&) const
{
if(!proxy)
{
return Ice::ObjectProxySeq();
}
//
// If the given proxy has an empty adapter id, we check if it's a
// well-known object. If it's a well-known object we use the
// registered proxy instead.
//
Ice::ObjectPrx prx = proxy;
if(prx->ice_getAdapterId().empty())
{
try
{
ObjectInfo info = _database->getObjectInfo(prx->ice_getIdentity());
prx = info.proxy;
}
catch(const ObjectNotRegisteredException&)
{
return Ice::ObjectProxySeq();
}
}
try
{
AdapterInfoSeq infos = _database->getAdapterInfo(prx->ice_getAdapterId());
if(infos.empty() || infos[0].replicaGroupId != prx->ice_getAdapterId())
{
// The adapter id doesn't refer to a replica group or the replica group is empty.
return Ice::ObjectProxySeq();
}
Ice::ObjectProxySeq proxies;
for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
{
assert(!p->id.empty());
proxies.push_back(prx->ice_adapterId(p->id));
}
return proxies;
}
catch(const AdapterNotExistException&)
{
return Ice::ObjectProxySeq();
}
}
示例4: assert
bool
IceInternal::RouterInfo::addProxy(const Ice::ObjectPrxPtr& proxy, const AddProxyCallbackPtr& callback)
{
assert(proxy);
{
IceUtil::Mutex::Lock sync(*this);
if(_identities.find(proxy->ice_getIdentity()) != _identities.end())
{
//
// Only add the proxy to the router if it's not already in our local map.
//
return true;
}
}
Ice::ObjectProxySeq proxies;
proxies.push_back(proxy);
AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy);
#ifdef ICE_CPP11_MAPPING
RouterInfoPtr self = this;
_router->addProxies_async(proxies,
[self, cookie](const Ice::ObjectProxySeq& proxies)
{
self->addProxyResponse(proxies, cookie);
},
[self, cookie](exception_ptr e)
{
try
{
rethrow_exception(e);
}
catch(const Ice::Exception& ex)
{
self->addProxyException(ex, cookie);
}
});
#else
_router->begin_addProxies(proxies,
newCallback_Router_addProxies(this,
&RouterInfo::addProxyResponse,
&RouterInfo::addProxyException),
cookie);
#endif
return false;
}
示例5: sync
Ice::ObjectProxySeq
ObjectCache::getObjectsByType(const string& type)
{
Lock sync(*this);
Ice::ObjectProxySeq proxies;
map<string, TypeEntry>::const_iterator p = _types.find(type);
if(p == _types.end())
{
return proxies;
}
const vector<ObjectEntryPtr>& objects = p->second.getObjects();
for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
proxies.push_back((*q)->getProxy());
}
return proxies;
}
示例6: sync
void
IceInternal::RouterInfo::addAndEvictProxies(const Ice::ObjectPrx& proxy, const Ice::ObjectProxySeq& evictedProxies)
{
IceUtil::Mutex::Lock sync(*this);
//
// Check if the proxy hasn't already been evicted by a concurrent addProxies call.
// If it's the case, don't add it to our local map.
//
multiset<Identity>::iterator p = _evictedIdentities.find(proxy->ice_getIdentity());
if(p != _evictedIdentities.end())
{
_evictedIdentities.erase(p);
}
else
{
//
// If we successfully added the proxy to the router,
// we add it to our local map.
//
_identities.insert(proxy->ice_getIdentity());
}
//
// We also must remove whatever proxies the router evicted.
//
for(Ice::ObjectProxySeq::const_iterator q = evictedProxies.begin(); q != evictedProxies.end(); ++q)
{
if(_identities.erase((*q)->ice_getIdentity()) == 0)
{
//
// It's possible for the proxy to not have been
// added yet in the local map if two threads
// concurrently call addProxies.
//
_evictedIdentities.insert((*q)->ice_getIdentity());
}
}
}
示例7:
Dispatch::Dispatch(int npro, Ice::ObjectPrx& proxy, CollectorPrx& collector):nproc(npro){
processor = std::vector < Cannon::ProcessorPrx > ();
IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(proxy);
Ice::ObjectProxySeq seq;
seq = query->findAllObjectsByType("::Cannon::Processor");
Cannon::ProcessorPrx pr;
int size = seq.size();
for(auto i:seq){
std::cout << i <<std::endl;
pr = Cannon::ProcessorPrx::checkedCast(i);
processor.push_back(pr);
}
for(int i =0; i<size; i++){
processor[i]->init( (int)(i/(int)sqrt(nproc)) , (int)(i%(int)sqrt(nproc)) ,processor[getNorth(i)], processor[getLeft(i)],(int)sqrt(nproc), collector);
}
}
示例8: e
//.........这里部分代码省略.........
else
{
// If adapter id's are defined for the topic manager or
// node adapters then we consider this an IceGrid based
// deployment.
string nodeAdapterId = properties->getProperty(name + ".Node.AdapterId");
// Validate first that the adapter ids match for the node
// and the topic manager otherwise some other deployment
// is being used.
const string suffix = ".TopicManager";
if(topicManagerAdapterId.empty() || nodeAdapterId.empty() ||
topicManagerAdapterId.replace(
topicManagerAdapterId.find(suffix), suffix.size(), ".Node") != nodeAdapterId)
{
Ice::Error error(communicator->getLogger());
error << "deployment error: `" << topicManagerAdapterId << "' prefix does not match `"
<< nodeAdapterId << "'";
throw IceBox::FailureException(__FILE__, __LINE__, "IceGrid deployment is incorrect");
}
// Determine the set of node id and node proxies.
//
// This is determined by locating all topic manager
// replicas, and then working out the node for that
// replica.
//
// We work out the node id by removing the instance
// name. The node id must follow.
//
IceGrid::LocatorPrx locator = IceGrid::LocatorPrx::checkedCast(communicator->getDefaultLocator());
assert(locator);
IceGrid::QueryPrx query = locator->getLocalQuery();
Ice::ObjectProxySeq replicas = query->findAllReplicas(
communicator->stringToProxy(instanceName + "/TopicManager"));
for(Ice::ObjectProxySeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
string adapterid = (*p)->ice_getAdapterId();
// Replace TopicManager with the node endpoint.
adapterid = adapterid.replace(adapterid.find(suffix), suffix.size(), ".Node");
// The adapter id must start with the instance name.
if(adapterid.find(instanceName) != 0)
{
Ice::Error error(communicator->getLogger());
error << "deployment error: `" << adapterid << "' does not start with `" << instanceName << "'";
throw IceBox::FailureException(__FILE__, __LINE__, "IceGrid deployment is incorrect");
}
// The node id follows. We find the first digit (the
// start of the node id, and then the end of the
// digits).
string::size_type start = instanceName.size();
while(start < adapterid.size() && !IceUtilInternal::isDigit(adapterid[start]))
{
++start;
}
string::size_type end = start;
while(end < adapterid.size() && IceUtilInternal::isDigit(adapterid[end]))
{
++end;
}
if(start == end)
{
示例9: out
//.........这里部分代码省略.........
_reaper = new ReapThread();
_reaper->start();
//
// Create the internal registry object adapter.
//
ObjectAdapterPtr registryAdapter = _communicator->createObjectAdapter("IceGrid.Registry.Internal");
registryAdapter->activate();
//
// Create the internal IceStorm service.
//
Identity registryTopicManagerId;
registryTopicManagerId.category = _instanceName;
registryTopicManagerId.name = "RegistryTopicManager";
_iceStorm = IceStorm::Service::create(_communicator,
registryAdapter,
registryAdapter,
"IceGrid.Registry",
registryTopicManagerId,
"Registry");
const IceStorm::TopicManagerPrx topicManager = _iceStorm->getTopicManager();
//
// Create the registry database.
//
_database = new Database(registryAdapter, topicManager, _instanceName, _traceLevels, getInfo());
_wellKnownObjects = new WellKnownObjectsManager(_database);
//
// Get the saved replica/node proxies and remove them from the
// database.
//
Ice::ObjectProxySeq proxies;
Ice::ObjectProxySeq::const_iterator p;
NodePrxSeq nodes;
proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
nodes.push_back(NodePrx::uncheckedCast(*p));
}
InternalRegistryPrxSeq replicas;
proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
//
// NOTE: The internal registry object must be added only once the
// node/replica proxies are retrieved and removed from the
// database. Otherwise, if some replica/node register as soon as
// the internal registry is setup we might clear valid proxies.
//
InternalRegistryPrx internalRegistry = setupInternalRegistry(registryAdapter);
if(_master)
{
nodes = registerReplicas(internalRegistry, replicas, nodes);
registerNodes(internalRegistry, nodes);
}
else
{
InternalReplicaInfoPtr info = _platform.getInternalReplicaInfo();
_session.create(_replicaName, info, _database, _wellKnownObjects, internalRegistry);
示例10: test
//.........这里部分代码省略.........
waitForServerState(admin, "Slave2", false);
info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator"));
// We eventually need to wait here for the update of the replicated objects to propagate to the replica.
nRetry = 0;
while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) != info && nRetry < maxRetry)
{
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime));
++nRetry;
}
test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info);
test(info.type == Ice::Locator::ice_staticId());
endpoints = info.proxy->ice_getEndpoints();
test(endpoints.size() == 2);
test(endpoints[0]->toString().find("-p 12050") != string::npos);
test(endpoints[1]->toString().find("-p 12051") != string::npos);
info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query"));
nRetry = 0;
while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) != info && nRetry < maxRetry)
{
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime));
++nRetry;
}
test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) == info);
test(info.type == IceGrid::Query::ice_staticId());
endpoints = info.proxy->ice_getEndpoints();
test(endpoints.size() == 2);
test(endpoints[0]->toString().find("-p 12050") != string::npos);
test(endpoints[1]->toString().find("-p 12051") != string::npos);
QueryPrx query;
query = QueryPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Query:" + endpoints[0]->toString()));
Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry");
test(objs.size() == 2);
query = QueryPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Query:" + endpoints[1]->toString()));
test(objs == query->findAllObjectsByType("::IceGrid::Registry"));
}
cout << "ok" << endl;
cout << "testing well-known IceGrid objects... " << flush;
{
//
// Test Registry well-known object (we have already tested
// admin session creation for the creation of the admin
// session above!)
//
RegistryPrx masterRegistry = RegistryPrx::checkedCast(
comm->stringToProxy("RepTestIceGrid/Registry")->ice_locator(replicatedLocator));
RegistryPrx slave1Registry = RegistryPrx::checkedCast(
comm->stringToProxy("RepTestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator));
SessionPrx session = masterRegistry->createSession("dummy", "dummy");
session->destroy();
if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl")
{
session = masterRegistry->createSessionFromSecureConnection();
session->destroy();
}
else
{
try
{
masterRegistry->createSessionFromSecureConnection();
}
catch(const PermissionDeniedException&)
示例11: test
void
allTests(const Ice::CommunicatorPtr& comm)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Query"));
test(query);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
set<string> serverReplicaIds;
serverReplicaIds.insert("Server1.ReplicatedAdapter");
serverReplicaIds.insert("Server2.ReplicatedAdapter");
serverReplicaIds.insert("Server3.ReplicatedAdapter");
set<string> svcReplicaIds;
svcReplicaIds.insert("IceBox1.Service1.Service1");
svcReplicaIds.insert("IceBox1.Service2.Service2");
svcReplicaIds.insert("IceBox1.Service3.Service3");
cout << "testing Query::findAllReplicas... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
Ice::ObjectProxySeq objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
removeServer(admin, "Server1");
removeServer(admin, "Server2");
removeServer(admin, "Server3");
}
cout << "ok" << endl;
cout << "testing replication with round-robin load balancing... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0));
obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false));
try
{
test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter");
admin->enableServer("Server1", false);
admin->enableServer("Server2", false);
admin->enableServer("Server3", false);
try
{
obj->getReplicaId();
test(false);
}
//.........这里部分代码省略.........
示例12: sync
void
NodeSessionManager::createdSession(const NodeSessionPrx& session)
{
bool activated;
{
Lock sync(*this);
activated = _activated;
}
//
// Synchronize the servers if the session is active and if the
// node adapter has been activated (otherwise, the servers will be
// synced after the node adapter activation, see activate()).
//
// We also set the replica observer to receive notifications of
// replica addition/removal.
//
if(session && activated)
{
try
{
session->setReplicaObserver(_node->getProxy());
syncServers(session);
}
catch(const Ice::LocalException&)
{
}
return;
}
//
// If there's no master session or if the node adapter isn't
// activated yet, we retrieve a list of the replicas either from
// the master or from the known replicas (the ones configured with
// Ice.Default.Locator) and we try to establish connections to
// each of the replicas.
//
InternalRegistryPrxSeq replicas;
if(session)
{
assert(!activated); // The node adapter isn't activated yet so
// we're not subscribed yet to the replica
// observer topic.
try
{
replicas = _thread->getRegistry()->getReplicas();
}
catch(const Ice::LocalException&)
{
}
}
else
{
vector<Ice::AsyncResultPtr> results;
for(vector<QueryPrx>::const_iterator q = _queryObjects.begin(); q != _queryObjects.end(); ++q)
{
results.push_back((*q)->begin_findAllObjectsByType(InternalRegistry::ice_staticId()));
}
map<Ice::Identity, Ice::ObjectPrx> proxies;
for(vector<Ice::AsyncResultPtr>::const_iterator p = results.begin(); p != results.end(); ++p)
{
QueryPrx query = QueryPrx::uncheckedCast((*p)->getProxy());
if(isDestroyed())
{
return;
}
try
{
Ice::ObjectProxySeq prxs = query->end_findAllObjectsByType(*p);
for(Ice::ObjectProxySeq::const_iterator q = prxs.begin(); q != prxs.end(); ++q)
{
//
// NOTE: We might override a good proxy here! We could improve this to make
// sure that we don't override the proxy for replica N if that proxy was
// obtained from replica N.
//
proxies[(*q)->ice_getIdentity()] = *q;
}
}
catch(const Ice::LocalException&)
{
// IGNORE
}
}
for(map<Ice::Identity, Ice::ObjectPrx>::const_iterator q = proxies.begin(); q != proxies.end(); ++q)
{
replicas.push_back(InternalRegistryPrx::uncheckedCast(q->second));
}
}
vector<NodeSessionKeepAliveThreadPtr> sessions;
{
Lock sync(*this);
if(_destroyed)
{
return;
//.........这里部分代码省略.........