本文整理汇总了C++中ice::CommunicatorPtr::identityToString方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorPtr::identityToString方法的具体用法?C++ CommunicatorPtr::identityToString怎么用?C++ CommunicatorPtr::identityToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorPtr
的用法示例。
在下文中一共展示了CommunicatorPtr::identityToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sync
void
NodeSessionManager::create(const NodeIPtr& node)
{
{
Lock sync(*this);
assert(!_node);
const_cast<NodeIPtr&>(_node) = node;
Ice::CommunicatorPtr communicator = _node->getCommunicator();
assert(communicator->getDefaultLocator());
Ice::Identity id = communicator->getDefaultLocator()->ice_getIdentity();
//
// Initialize the IceGrid::Query objects. The IceGrid::Query
// interface is used to lookup the registry proxy in case it
// becomes unavailable. Since replicas might not always have
// an up to date registry proxy, we need to query all the
// replicas.
//
Ice::EndpointSeq endpoints = communicator->getDefaultLocator()->ice_getEndpoints();
id.name = "Query";
QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
Ice::EndpointSeq singleEndpoint;
singleEndpoint.push_back(*p);
_queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
}
id.name = "InternalRegistry-Master";
_master = InternalRegistryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
_thread = new Thread(*this);
_thread->start();
}
//
// Try to create the session. It's important that we wait for the
// creation of the session as this will also try to create sessions
// with replicas (see createdSession below) and this must be done
// before the node is activated.
//
_thread->tryCreateSession(true, IceUtil::Time::seconds(3));
}
示例2: catch
ObjectInfo
IceGrid::toObjectInfo(const Ice::CommunicatorPtr& communicator, const ObjectDescriptor& object, const string& adapterId)
{
ObjectInfo info;
info.type = object.type;
ostringstream proxyStr;
proxyStr << "\"" << communicator->identityToString(object.id) << "\"";
if(!object.proxyOptions.empty())
{
proxyStr << ' ' << object.proxyOptions;
}
proxyStr << " @ " << adapterId;
try
{
info.proxy = communicator->stringToProxy(proxyStr.str());
}
catch(const Ice::ProxyParseException&)
{
ostringstream fallbackProxyStr;
fallbackProxyStr << "\"" << communicator->identityToString(object.id) << "\"" << " @ " << adapterId;
info.proxy = communicator->stringToProxy(fallbackProxyStr.str());
}
return info;
}
示例3: assert
IceGrid::QueryPrx
getDefaultQuery( const orcaice::Context& context )
{
Ice::CommunicatorPtr ic = context.communicator();
assert( ic );
Ice::ObjectPrx locatorPrx = ic->getDefaultLocator();
Ice::Identity locatorId = locatorPrx->ice_getIdentity();
Ice::Identity queryId;
queryId.category = locatorId.category;
queryId.name = "Query";
Ice::ObjectPrx objPrx = ic->stringToProxy( ic->identityToString( queryId ) );
IceGrid::QueryPrx queryPrx;
try {
// objPrx->ice_ping();
// string address = orcacm::connectionToRemoteAddress( queryPrx->ice_getConnection()->toString() );
// std::ostringstream os;
// os<<"Registry ping successful: "<<data.address;
// context.tracer().debug( os.str() );
queryPrx = IceGrid::QueryPrx::checkedCast( objPrx );
}
catch ( const Ice::Exception& e ) {
// what do we do?
ostringstream os;
os << "(while looking for IceGrid Query interface) :"<<e.what();
context.tracer().warning( os.str() );
}
return queryPrx;
}
示例4: if
//.........这里部分代码省略.........
test(b1->ice_toString() == "test -t -p 6.5 -e 1.0");
try
{
b1 = communicator->stringToProxy("test:[email protected]");
test(false);
}
catch(const Ice::EndpointParseException&)
{
}
// This is an unknown endpoint warning, not a parse exception.
//
//try
//{
// b1 = communicator->stringToProxy("test -f the:facet:tcp");
// test(false);
//}
//catch(const Ice::EndpointParseException&)
//{
//}
try
{
b1 = communicator->stringToProxy("test::tcp");
test(false);
}
catch(const Ice::EndpointParseException&)
{
}
//
// Test for bug ICE-5543: escaped escapes in stringToIdentity
//
Ice::Identity id = { "test", ",X2QNUAzSBcJ_e$AV;E\\" };
Ice::Identity id2 = communicator->stringToIdentity(communicator->identityToString(id));
test(id == id2);
id.name = "test";
id.category = ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\";
id2 = communicator->stringToIdentity(communicator->identityToString(id));
test(id == id2);
cout << "ok" << endl;
cout << "testing propertyToProxy... " << flush;
Ice::PropertiesPtr prop = communicator->getProperties();
string propertyPrefix = "Foo.Proxy";
prop->setProperty(propertyPrefix, "test:default -p 12010");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty());
string property;
property = propertyPrefix + ".Locator";
test(!b1->ice_getLocator());
prop->setProperty(property, "locator:default -p 10000");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
prop->setProperty(property, "");
property = propertyPrefix + ".LocatorCacheTimeout";
test(b1->ice_getLocatorCacheTimeout() == -1);
prop->setProperty(property, "1");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocatorCacheTimeout() == 1);
prop->setProperty(property, "");
示例5: test
//.........这里部分代码省略.........
{
// Expected to fail once they endpoints have been updated in the background.
}
ic->destroy();
}
cout << "ok" << endl;
cout << "testing proxy from server after shutdown... " << flush;
hello = obj->getReplicatedHello();
obj->shutdown();
manager->startServer();
hello->sayHello();
cout << "ok" << endl;
cout << "testing object migration... " << flush;
hello = HelloPrx::checkedCast(communicator->stringToProxy("hello"));
obj->migrateHello();
// TODO: enable after fixing ICE-5489
//hello->ice_getConnection()->close(false);
hello->sayHello();
obj->migrateHello();
hello->sayHello();
obj->migrateHello();
hello->sayHello();
cout << "ok" << endl;
cout << "testing locator encoding resolution... " << flush;
hello = HelloPrx::checkedCast(communicator->stringToProxy("hello"));
count = locator->getRequestCount();
communicator->stringToProxy("[email protected]")->ice_encodingVersion(Ice::Encoding_1_1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping();
test(++count == locator->getRequestCount());
communicator->stringToProxy("test -e [email protected]")->ice_ping();
test(++count == locator->getRequestCount());
cout << "ok" << endl;
cout << "shutdown server... " << flush;
obj->shutdown();
cout << "ok" << endl;
cout << "testing whether server is gone... " << flush;
try
{
obj2->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
try
{
obj3->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
try
{
obj5->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
cout << "ok" << endl;
cout << "testing indirect proxies to collocated objects... " << flush;
//
// Set up test for calling a collocated object through an indirect, adapterless reference.
//
Ice::PropertiesPtr properties = communicator->getProperties();
properties->setProperty("Ice.PrintAdapterReady", "0");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "default");
adapter->setLocator(locator);
Ice::Identity id;
id.name = IceUtil::generateUUID();
registry->addObject(adapter->add(new HelloI, id));
adapter->activate();
try
{
HelloPrx helloPrx = HelloPrx::checkedCast(communicator->stringToProxy(communicator->identityToString(id)));
Ice::ConnectionPtr connection = helloPrx->ice_getConnection();
test(false);
}
catch(const Ice::CollocationOptimizationException&)
{
}
adapter->deactivate();
cout << "ok" << endl;
cout << "shutdown server manager... " << flush;
manager->shutdown();
cout << "ok" << endl;
}
示例6: fs
//.........这里部分代码省略.........
{
IceDB::Env env(dbPath, 2, mapSize);
IceDB::ReadWriteTxn txn(env);
if(debug)
{
consoleOut << "Writing LLU Map:" << endl;
}
IceDB::Dbi<string,IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream>
lluMap(txn, "llu", dbContext, MDB_CREATE);
for(IceStormElection::StringLogUpdateDict::const_iterator p = data.llus.begin(); p != data.llus.end(); ++p)
{
if(debug)
{
consoleOut << " KEY = " << p->first << endl;
}
lluMap.put(txn, p->first, p->second);
}
if(debug)
{
consoleOut << "Writing Subscriber Map:" << endl;
}
IceDB::Dbi<IceStorm::SubscriberRecordKey, IceStorm::SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
subscriberMap(txn, "subscribers", dbContext, MDB_CREATE);
for(IceStorm::SubscriberRecordDict::const_iterator q = data.subscribers.begin(); q != data.subscribers.end(); ++q)
{
if(debug)
{
consoleOut << " KEY = TOPIC(" << communicator->identityToString(q->first.topic)
<< ") ID(" << communicator->identityToString(q->first.id) << ")" << endl;
}
subscriberMap.put(txn, q->first, q->second);
}
txn.commit();
env.close();
}
}
else
{
consoleOut << "Exporting database from directory " << dbPath << " to file " << dbFile << endl;
{
IceDB::Env env(dbPath, 2);
IceDB::ReadOnlyTxn txn(env);
if(debug)
{
consoleOut << "Reading LLU Map:" << endl;
}
IceDB::Dbi<string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream>
lluMap(txn, "llu", dbContext, 0);
string s;
IceStormElection::LogUpdate llu;
IceDB::ReadOnlyCursor<string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream> lluCursor(lluMap, txn);
while(lluCursor.get(s, llu, MDB_NEXT))
{
if(debug)
{
示例7: if
int
run(const Ice::StringSeq& args)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
vector<string> commands;
try
{
commands = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << e.reason << endl;
usage(args[0]);
return 1;
}
if(opts.isSet("help"))
{
usage(args[0]);
return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
return 0;
}
if(commands.empty())
{
usage(args[0]);
return 1;
}
Ice::ObjectPrxPtr base = communicator->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy");
if(base == 0)
{
//
// The old deprecated way to retrieve the service manager proxy
//
Ice::PropertiesPtr properties = communicator->getProperties();
Ice::Identity managerIdentity;
managerIdentity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
managerIdentity.name = "ServiceManager";
string managerProxy;
if(properties->getProperty("Ice.Default.Locator").empty())
{
string managerEndpoints = properties->getProperty("IceBox.ServiceManager.Endpoints");
if(managerEndpoints.empty())
{
consoleErr << args[0] << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return 1;
}
managerProxy = "\"" + communicator->identityToString(managerIdentity) + "\" :" + managerEndpoints;
}
else
{
string managerAdapterId = properties->getProperty("IceBox.ServiceManager.AdapterId");
if(managerAdapterId.empty())
{
consoleErr << args[0] << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return 1;
}
managerProxy = "\"" + communicator->identityToString(managerIdentity) + "\" @" + managerAdapterId;
}
base = communicator->stringToProxy(managerProxy);
}
IceBox::ServiceManagerPrxPtr manager = ICE_CHECKED_CAST(IceBox::ServiceManagerPrx, base);
if(!manager)
{
consoleErr << args[0] << ": `" << base << "' is not an IceBox::ServiceManager" << endl;
return 1;
}
for(vector<string>::const_iterator r = commands.begin(); r != commands.end(); ++r)
{
if((*r) == "shutdown")
{
manager->shutdown();
}
else if((*r) == "start")
{
if(++r == commands.end())
{
consoleErr << args[0] << ": no service name specified." << endl;
return 1;
}
try
{
//.........这里部分代码省略.........
示例8: if
bool
FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, const string& name, const DataList& args,
DataPtr& result, const DataFactoryPtr& factory,
const ErrorReporterPtr& errorReporter)
{
//
// Global function.
//
if(name == "typeOf")
{
if(args.size() != 1)
{
errorReporter->error("typeOf() requires one argument");
}
result = factory->createString(typeToString(args.front()->getType()), false);
return true;
}
else if(name == "generateUUID")
{
if(args.size() != 0)
{
errorReporter->error("generateUUID() accepts no arguments");
}
result = factory->createString(IceUtil::generateUUID(), false);
return true;
}
else if(name == "stringToIdentity")
{
StringDataPtr str;
if(args.size() > 0)
{
str = StringDataPtr::dynamicCast(args.front());
}
if(args.size() != 1 || !str)
{
errorReporter->error("stringToIdentity() requires a string argument");
}
//
// Parse the identity string.
//
string idstr = str->stringValue();
Ice::Identity id;
try
{
id = communicator->stringToIdentity(idstr);
}
catch(const Ice::IdentityParseException& ex)
{
errorReporter->error("error in stringToIdentity():\n" + ex.str);
}
//
// Create a data representation of Ice::Identity.
//
Slice::UnitPtr unit = str->getType()->unit();
Slice::TypeList l = unit->lookupType("::Ice::Identity", false);
assert(!l.empty());
DataPtr identity = factory->create(l.front(), false);
StringDataPtr member;
member = StringDataPtr::dynamicCast(identity->getMember("name"));
assert(member);
member->setValue(id.name);
member = StringDataPtr::dynamicCast(identity->getMember("category"));
assert(member);
member->setValue(id.category);
result = identity;
return true;
}
else if(name == "identityToString")
{
StructDataPtr identity;
if(args.size() > 0)
{
identity = StructDataPtr::dynamicCast(args.front());
}
if(identity)
{
Slice::TypePtr argType = identity->getType();
Slice::StructPtr st = Slice::StructPtr::dynamicCast(argType);
if(!st || st->scoped() != "::Ice::Identity")
{
identity = 0;
}
}
if(args.size() != 1 || !identity)
{
errorReporter->error("identityToString() requires a argument of type ::Ice::Identity");
}
//
// Compose the identity.
//
Ice::Identity id;
StringDataPtr member;
member = StringDataPtr::dynamicCast(identity->getMember("name"));
assert(member);
id.name = member->stringValue();
member = StringDataPtr::dynamicCast(identity->getMember("category"));
assert(member);
//.........这里部分代码省略.........
示例9: tprintf
//.........这里部分代码省略.........
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
prop->setProperty(property, "");
#endif
// Now retest with an indirect proxy.
#ifdef ICEE_HAS_LOCATOR
prop->setProperty(propertyPrefix, "test");
property = propertyPrefix + ".Locator";
prop->setProperty(property, "locator:default -p 10000");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
prop->setProperty(property, "");
#endif
prop->setProperty(propertyPrefix, "test:default -p 12010 -t 10000");
#ifdef ICEE_HAS_ROUTER
property = propertyPrefix + ".Router";
test(!b1->ice_getRouter());
prop->setProperty(property, "router:default -p 10000");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getRouter() && b1->ice_getRouter()->ice_getIdentity().name == "router");
prop->setProperty(property, "");
#endif
tprintf("ok\n");
tprintf("testing ice_getCommunicator... ");
test(base->ice_getCommunicator() == communicator);
tprintf("ok\n");
tprintf("testing proxy methods... ");
test(communicator->identityToString(base->ice_identity(communicator->stringToIdentity("other"))->ice_getIdentity())
== "other");
test(base->ice_facet("facet")->ice_getFacet() == "facet");
test(base->ice_adapterId("id")->ice_getAdapterId() == "id");
test(base->ice_twoway()->ice_isTwoway());
test(base->ice_oneway()->ice_isOneway());
test(base->ice_batchOneway()->ice_isBatchOneway());
test(base->ice_datagram()->ice_isDatagram());
test(base->ice_batchDatagram()->ice_isBatchDatagram());
test(base->ice_secure(true)->ice_isSecure());
test(!base->ice_secure(false)->ice_isSecure());
tprintf("ok\n");
tprintf("testing proxy comparison... ");
test(communicator->stringToProxy("foo") == communicator->stringToProxy("foo"));
test(communicator->stringToProxy("foo") != communicator->stringToProxy("foo2"));
test(communicator->stringToProxy("foo") < communicator->stringToProxy("foo2"));
test(!(communicator->stringToProxy("foo2") < communicator->stringToProxy("foo")));
Ice::ObjectPrx compObj = communicator->stringToProxy("foo");
test(compObj->ice_facet("facet") == compObj->ice_facet("facet"));
test(compObj->ice_facet("facet") != compObj->ice_facet("facet1"));
test(compObj->ice_facet("facet") < compObj->ice_facet("facet1"));
test(!(compObj->ice_facet("facet") < compObj->ice_facet("facet")));
test(compObj->ice_oneway() == compObj->ice_oneway());
test(compObj->ice_oneway() != compObj->ice_twoway());
test(compObj->ice_twoway() < compObj->ice_oneway());
test(!(compObj->ice_oneway() < compObj->ice_twoway()));
test(compObj->ice_secure(true) == compObj->ice_secure(true));
示例10: test
//.........这里部分代码省略.........
communicator->stringToProxy("test")->ice_locatorCacheTimeout(-1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_ping();
test(count == locator->getRequestCount());
test(communicator->stringToProxy("test")->ice_locatorCacheTimeout(99)->ice_getLocatorCacheTimeout() == 99);
cout << "ok" << endl;
cout << "testing proxy from server... " << flush;
HelloPrx hello = obj->getHello();
test(hello->ice_getAdapterId() == "TestAdapter");
hello->sayHello();
hello = obj->getReplicatedHello();
test(hello->ice_getAdapterId() == "ReplicatedAdapter");
hello->sayHello();
cout << "ok" << endl;
cout << "testing proxy from server after shutdown... " << flush;
obj->shutdown();
manager->startServer();
hello->sayHello();
cout << "ok" << endl;
cout << "testing object migration... " << flush;
hello = HelloPrx::checkedCast(communicator->stringToProxy("hello"));
obj->migrateHello();
hello->sayHello();
obj->migrateHello();
hello->sayHello();
obj->migrateHello();
hello->sayHello();
cout << "ok" << endl;
cout << "shutdown server... " << flush;
obj->shutdown();
cout << "ok" << endl;
cout << "testing whether server is gone... " << flush;
try
{
obj2->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
try
{
obj3->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
try
{
obj5->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
}
cout << "ok" << endl;
cout << "testing indirect proxies to collocated objects... " << flush;
//
// Set up test for calling a collocated object through an indirect, adapterless reference.
//
Ice::PropertiesPtr properties = communicator->getProperties();
properties->setProperty("Ice.PrintAdapterReady", "0");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "default");
adapter->setLocator(locator);
TestLocatorRegistryPrx registry = TestLocatorRegistryPrx::checkedCast(locator->getRegistry());
test(registry);
Ice::Identity id;
id.name = IceUtil::generateUUID();
registry->addObject(adapter->add(new HelloI, id));
adapter->activate();
try
{
HelloPrx helloPrx = HelloPrx::checkedCast(communicator->stringToProxy(communicator->identityToString(id)));
Ice::ConnectionPtr connection = helloPrx->ice_getConnection();
test(false);
}
catch(const Ice::CollocationOptimizationException&)
{
}
adapter->deactivate();
cout << "ok" << endl;
cout << "shutdown server manager... " << flush;
manager->shutdown();
cout << "ok" << endl;
}