bool PSIDynamicICESender::Connect() { try { if(!FCommunicatorPtr) { Ice::StringSeq args; string Tmp=GetICECommunicatorConfig(FHostIP,FHostPort); args.push_back(Tmp); args.push_back("Ice.ACM.Client=0"); args.push_back("Ice.MessageSizeMax=30000"); // FCommunicator = Ice::initialize(args); FCommunicatorPtr = Ice::initialize(); cout<<FServiceName+":通讯器成功初始化!" <<std::endl; } Ice::ObjectPrx base=FCommunicatorPtr->stringToProxy(GetICEObjectConfig(FHostIP,FHostPort)); FSendBufferPrx=InfoDTV::Multiplexer::Dynamic::Provider::DynamicBufferTransferPrx::checkedCast(base); if(!FSendBufferPrx) { if(FCommunicatorPtr) { FCommunicatorPtr->destroy(); FCommunicatorPtr=NULL; } return false; } } catch (const Ice::Exception & e) { cout<<string(e.what())<<"dddd"<<std::endl; if(FCommunicatorPtr) { FCommunicatorPtr->destroy(); FCommunicatorPtr=NULL; } return false; } catch (...) { cout<<FServiceName+":Connect:通讯器初始化失败!"<<std::endl; // Console.Error.WriteLine(ex); if(FCommunicatorPtr) { FCommunicatorPtr->destroy(); FCommunicatorPtr=NULL; } return false; } return true; }
StringSeq AdminI::getAllRegistryNames(const Current&) const { Ice::StringSeq replicas = _database->getReplicaCache().getAll(""); replicas.push_back(_registry->getName()); return replicas; }
bool IcePy::listToStringSeq(PyObject* l, Ice::StringSeq& seq) { assert(PyList_Check(l)); Py_ssize_t sz = PyList_GET_SIZE(l); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PyList_GET_ITEM(l, i); if(!item) { return false; } string str; if(checkString(item)) { str = getString(item); } else if(item != Py_None) { PyErr_Format(PyExc_ValueError, STRCAST("list element must be a string")); return false; } seq.push_back(str); } return true; }
bool IcePy::tupleToStringSeq(PyObject* t, Ice::StringSeq& seq) { assert(PyTuple_Check(t)); int sz = static_cast<int>(PyTuple_GET_SIZE(t)); for(int i = 0; i < sz; ++i) { PyObject* item = PyTuple_GET_ITEM(t, i); if(!item) { return false; } string str; if(checkString(item)) { str = getString(item); } else if(item != Py_None) { PyErr_Format(PyExc_ValueError, STRCAST("tuple element must be a string")); return false; } seq.push_back(str); } return true; }
bool IcePHP::extractStringArray(zval* zv, Ice::StringSeq& seq) { if(Z_TYPE_P(zv) != IS_ARRAY) { string s = zendTypeToString(Z_TYPE_P(zv)); invalidArgument("expected an array of strings but received %s", s.c_str()); return false; } HashTable* arr = Z_ARRVAL_P(zv); zval* val; ZEND_HASH_FOREACH_VAL(arr, val) { if(Z_TYPE_P(val) != IS_STRING) { invalidArgument("array element must be a string"); return false; } string s(Z_STRVAL_P(val), Z_STRLEN_P(val)); seq.push_back(s); } ZEND_HASH_FOREACH_END(); return true; }
Ice::StringSeq ReplicaGroupFilterI::filter(const string& /* replicaGroupId */, const Ice::StringSeq& adapters, const Ice::ConnectionPtr&, const Ice::Context& ctx) { Ice::Context::const_iterator p = ctx.find("currency"); if(p == ctx.end()) { return adapters; } string currency = p->second; // // Get the Currencies property value from the server descriptor // that owns the adapter and only keep adapters for servers that // are configured with the currency specified in the client // context. // Ice::StringSeq filteredAdapters; for(Ice::StringSeq::const_iterator p = adapters.begin(); p != adapters.end(); ++p) { if(_facade->getPropertyForAdapter(*p, "Currencies").find(currency) != string::npos) { filteredAdapters.push_back(*p); } } return filteredAdapters; }
int main(int argc, char* argv[]) { ifstream in("./config/configPath"); if(!in) { test(false); } if(!getline(in, configPath)) { test(false); } try { cout << "testing load properties from UTF-8 path... " << flush; Ice::PropertiesPtr properties = Ice::createProperties(); properties->load(configPath); test(properties->getProperty("Ice.Trace.Network") == "1"); test(properties->getProperty("Ice.Trace.Protocol") == "1"); test(properties->getProperty("Config.Path") == configPath); test(properties->getProperty("Ice.ProgramName") == "PropertiesClient"); cout << "ok" << endl; } catch(const Ice::Exception& ex) { cerr << ex << endl; return EXIT_FAILURE; } cout << "testing load properties from UTF-8 path using Ice::Application... " << flush; Client c; c.main(argc, argv, configPath.c_str()); cout << "ok" << endl; try { // // Try to load multiple config files. // cout << "testing using Ice.Config with multiple config files... " << flush; Ice::PropertiesPtr properties; Ice::StringSeq args; args.push_back("--Ice.Config=config/config.1, config/config.2, config/config.3"); IceUtilInternal::ArgVector a(args); properties = Ice::createProperties(a.argc, a.argv); test(properties->getProperty("Config1") == "Config1"); test(properties->getProperty("Config2") == "Config2"); test(properties->getProperty("Config3") == "Config3"); cout << "ok" << endl; } catch(const Ice::Exception& ex) { cerr << ex << endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }
Ice::StringSeq NodeSessionI::getServers(const Ice::Current&) const { ServerEntrySeq servers = _database->getNode(_info->name)->getServers(); Ice::StringSeq names; for(ServerEntrySeq::const_iterator p = servers.begin(); p != servers.end(); ++p) { names.push_back((*p)->getId()); } return names; }
Demo::BookPrx LibraryI::createBook(const Demo::BookDescription& description, const Ice::Current& c) { IceUtil::Mutex::Lock lock(*this); BookPrx book = IsbnToBook(c.adapter)(description.isbn); try { book->ice_ping(); // // The book already exists. // throw BookExistsException(); } catch(const Ice::ObjectNotExistException&) { // // Book doesn't exist, ignore the exception. // } BookPtr bookI = new BookI(this); bookI->description = description; // // Create a new Ice Object in the evictor, using the new identity // and the new Servant. // // This can throw EvictorDeactivatedException (which indicates an // internal error). The exception is currently ignored. // Ice::Identity ident = createBookIdentity(description.isbn); _evictor->add(bookI, ident); // // Add the isbn number to the authors map. // Ice::StringSeq isbnSeq; StringIsbnSeqDict::iterator p = _authors.find(description.authors); if(p != _authors.end()) { isbnSeq = p->second; } isbnSeq.push_back(description.isbn); _authors.put(StringIsbnSeqDict::value_type(description.authors, isbnSeq)); return book; }
Ice::StringSeq MetricsAdminI::getMetricsViewNames(Ice::StringSeq& disabledViews, const Current&) { Ice::StringSeq enabledViews; Lock sync(*this); for(map<string, MetricsViewIPtr>::const_iterator p = _views.begin(); p != _views.end(); ++p) { enabledViews.push_back(p->first); } #if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES) for(set<string>::const_iterator p = _disabledViews.begin(); p != _disabledViews.end(); ++p) { disabledViews.push_back(*p); } #else disabledViews.insert(disabledViews.end(), _disabledViews.begin(), _disabledViews.end()); #endif return enabledViews; }
void ICEBufferReciver::InitCommunicator() { try { Ice::StringSeq args; args.push_back(GetICECommunicatorConfig()); // FCommunicator = Ice::initialize(args); FCommunicator = Ice::initialize(); Log(FServiceName+":通讯器成功初始化!" ); } catch (const Ice::Exception & e) { Log(string(e.what())); } catch (...) { Log(FServiceName+":通讯器初始化失败!"); // Console.Error.WriteLine(ex); } }
void ServerEntry::released(const SessionIPtr& session) { if(!_loaded.get() && !_load.get()) { return; } ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor; // // If the server has the session activation mode, we re-load the // server on the node as its deployment might have changed (it's // possible to use ${session.*} variable with server with the // session activation mode. Synchronizing the server will also // shutdown the server on the node. // if(desc->activation == "session") { _updated = true; if(!_load.get()) { _load.reset(_loaded.release()); } _load->sessionId = ""; _session = 0; } TraceLevelsPtr traceLevels = _cache.getTraceLevels(); Glacier2::IdentitySetPrx identitySet = session->getGlacier2IdentitySet(); Glacier2::StringSetPrx adapterIdSet = session->getGlacier2AdapterIdSet(); if(identitySet && adapterIdSet) { ServerHelperPtr helper = createHelper(desc); multiset<string> adapterIds; multiset<Ice::Identity> identities; helper->getIds(adapterIds, identities); try { // // SunCC won't accept the following: // // ctl->adapterIds()->remove(Ice::StringSeq(adapterIds.begin(), adapterIds.end())); // ctl->identities()->remove(Ice::IdentitySeq(identities.begin(), identities.end())); // Ice::StringSeq adapterIdSeq; for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p) { adapterIdSeq.push_back(*p); } Ice::IdentitySeq identitySeq; for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q) { identitySeq.push_back(*q); } adapterIdSet->remove(adapterIdSeq); identitySet->remove(identitySeq); } catch(const Ice::LocalException& ex) { if(traceLevels && traceLevels->server > 0) { Ice::Trace out(traceLevels->logger, traceLevels->serverCat); out << "couldn't remove Glacier2 filters for server `" << _id << "' allocated by `"; out << session->getId() << ":\n" << ex; } } } if(traceLevels && traceLevels->server > 1) { Ice::Trace out(traceLevels->logger, traceLevels->serverCat); out << "server `" << _id << "' released by `" << session->getId() << "' (" << _count << ")"; } }
bool FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOffset, Ice::StringSeq& lines) { assert(size > 0); if(size > _messageSizeMax) { size = _messageSizeMax; } if(size <= 5) { throw FileNotAvailableException("maximum bytes per read request is too low"); } IceUtilInternal::ifstream is(file); // file is a UTF-8 string if(is.fail()) { throw FileNotAvailableException("failed to open file `" + file + "'"); } // // Check if the requested offset is past the end of the file, if // that's the case return an empty sequence of lines and indicate // the EOF. // is.seekg(0, ios::end); if(offset >= is.tellg()) { newOffset = is.tellg(); lines = Ice::StringSeq(); return true; } // // Read lines from the file until we read enough or reached EOF. // newOffset = offset; lines = Ice::StringSeq(); is.seekg(static_cast<streamoff>(offset), ios::beg); int totalSize = 0; string line; for(int i = 0; is.good(); ++i) { getline(is, line); int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case) if(lineSize + totalSize > size) { if(totalSize + 5 < size) { // There's some room left for a part of the string, return a partial string line = line.substr(0, size - totalSize - 5); lines.push_back(line); newOffset += line.size(); } else { lines.push_back(""); } return false; // We didn't reach the end of file, we've just reached the size limit! } totalSize += lineSize; lines.push_back(line); // // If there was a partial read update the offset using the current line size, // otherwise we have read a new complete line and we can use tellg to update // the offset. // if(!is.good()) { newOffset += line.size(); } else { newOffset = is.tellg(); } } if(is.bad()) { throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'"); } return is.eof(); }
int main(int argc, char* argv[]) { #ifdef ICE_STATIC_LIBS Ice::registerIceSSL(); #endif ifstream in("./config/configPath"); if(!in) { test(false); } if(!getline(in, configPath)) { test(false); } try { cout << "testing load properties from UTF-8 path... " << flush; Ice::PropertiesPtr properties = Ice::createProperties(); properties->load(configPath); test(properties->getProperty("Ice.Trace.Network") == "1"); test(properties->getProperty("Ice.Trace.Protocol") == "1"); test(properties->getProperty("Config.Path") == configPath); test(properties->getProperty("Ice.ProgramName") == "PropertiesClient"); cout << "ok" << endl; } catch(const Ice::Exception& ex) { cerr << ex << endl; return EXIT_FAILURE; } cout << "testing load properties from UTF-8 path using Ice::Application... " << flush; Client c; c.main(argc, argv, configPath.c_str()); cout << "ok" << endl; try { // // Try to load multiple config files. // cout << "testing using Ice.Config with multiple config files... " << flush; Ice::PropertiesPtr properties; Ice::StringSeq args; args.push_back("--Ice.Config=config/config.1, config/config.2, config/config.3"); properties = Ice::createProperties(args); test(properties->getProperty("Config1") == "Config1"); test(properties->getProperty("Config2") == "Config2"); test(properties->getProperty("Config3") == "Config3"); cout << "ok" << endl; } catch(const Ice::Exception& ex) { cerr << ex << endl; return EXIT_FAILURE; } try { cout << "testing configuration file escapes... " << flush; Ice::PropertiesPtr properties; Ice::StringSeq args; args.push_back("--Ice.Config=config/escapes.cfg"); properties = Ice::createProperties(args); string props[] = { "Foo\tBar", "3", "Foo\\tBar", "4", "Escape\\ Space", "2", "Prop1", "1", "Prop2", "2", "Prop3", "3", "My Prop1", "1", "My Prop2", "2", "My.Prop1", "a property", "My.Prop2", "a property", "My.Prop3", " a property ", "My.Prop4", " a property ", "My.Prop5", "a \\ property", "foo=bar", "1", "foo#bar", "2", "foo bar", "3", "A", "1", "B", "2 3 4", "C", "5=#6", "AServer", "\\\\server\\dir", "BServer", "\\server\\dir", "" } ; for(size_t i = 0; props[i] != ""; i += 2) { test(properties->getProperty(props[i]) == props[i + 1]); } cout << "ok" << endl; } catch(const Ice::Exception& ex) { cerr << ex << endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }
bool NodeI::canRemoveServerDirectory(const string& name) { // // Check if there's files which we didn't create. // Ice::StringSeq c = readDirectory(_serversDir + "/" + name); set<string> contents(c.begin(), c.end()); contents.erase("dbs"); contents.erase("config"); contents.erase("distrib"); contents.erase("revision"); contents.erase("data"); Ice::StringSeq serviceDataDirs; for(set<string>::const_iterator p = contents.begin(); p != contents.end(); ++p) { if(p->find("data_") != 0) { return false; } serviceDataDirs.push_back(*p); } if(!contents.empty()) { return false; } c = readDirectory(_serversDir + "/" + name + "/config"); for(Ice::StringSeq::const_iterator p = c.begin() ; p != c.end(); ++p) { if(p->find("config") != 0) { return false; } } if(IceUtilInternal::directoryExists(_serversDir + "/" + name + "/dbs")) { c = readDirectory(_serversDir + "/" + name + "/dbs"); for(Ice::StringSeq::const_iterator p = c.begin() ; p != c.end(); ++p) { try { Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p); files.erase(remove(files.begin(), files.end(), "DB_CONFIG"), files.end()); files.erase(remove(files.begin(), files.end(), "__Freeze"), files.end()); if(!files.empty()) { return false; } } catch(const string&) { return false; } } } if(IceUtilInternal::directoryExists(_serversDir + "/" + name + "/data")) { if(!readDirectory(_serversDir + "/" + name + "/data").empty()) { return false; } } for(Ice::StringSeq::const_iterator p = serviceDataDirs.begin(); p != serviceDataDirs.end(); ++p) { try { if(!readDirectory(_serversDir + "/" + name + "/" + *p).empty()) { return false; } } catch(const string&) { return false; } } return true; }