本文整理汇总了C++中PropertiesPtr::getPropertiesForPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertiesPtr::getPropertiesForPrefix方法的具体用法?C++ PropertiesPtr::getPropertiesForPrefix怎么用?C++ PropertiesPtr::getPropertiesForPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertiesPtr
的用法示例。
在下文中一共展示了PropertiesPtr::getPropertiesForPrefix方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
MetricsMapI::MetricsMapI(const std::string& mapPrefix, const PropertiesPtr& properties) :
_properties(properties->getPropertiesForPrefix(mapPrefix)),
_retain(properties->getPropertyAsIntWithDefault(mapPrefix + "RetainDetached", 10)),
_accept(parseRule(properties, mapPrefix + "Accept")),
_reject(parseRule(properties, mapPrefix + "Reject"))
{
validateProperties(mapPrefix, properties);
string groupBy = properties->getPropertyWithDefault(mapPrefix + "GroupBy", "id");
vector<string>& groupByAttributes = const_cast<vector<string>&>(_groupByAttributes);
vector<string>& groupBySeparators = const_cast<vector<string>&>(_groupBySeparators);
if(!groupBy.empty())
{
string v;
bool attribute = IceUtilInternal::isAlpha(groupBy[0]) || IceUtilInternal::isDigit(groupBy[0]);
if(!attribute)
{
groupByAttributes.push_back("");
}
for(string::const_iterator p = groupBy.begin(); p != groupBy.end(); ++p)
{
bool isAlphaNum = IceUtilInternal::isAlpha(*p) || IceUtilInternal::isDigit(*p) || *p == '.';
if(attribute && !isAlphaNum)
{
groupByAttributes.push_back(v);
v = *p;
attribute = false;
}
else if(!attribute && isAlphaNum)
{
groupBySeparators.push_back(v);
v = *p;
attribute = true;
}
else
{
v += *p;
}
}
if(attribute)
{
groupByAttributes.push_back(v);
}
else
{
groupBySeparators.push_back(v);
}
}
}
示例2: reload
void Analyzer::reload(const PropertiesPtr& properties) {
MCE_INFO("Analyzer::reload type: " << type_);
int defaultmin = properties->getPropertyAsIntWithDefault("Analyzer."+type_+".Default.Min", INT_MIN);
int defaultmax = properties->getPropertyAsIntWithDefault("Analyzer."+type_+".Default.Max", INT_MAX);
int defaultmoremin = properties->getPropertyAsIntWithDefault("Analyzer."+type_+".Default.MoreMin", INT_MIN);
int defaultmoremax = properties->getPropertyAsIntWithDefault("Analyzer."+type_+".Default.MoreMax", INT_MAX);
LimiterPtr defaulter = new Limiter(defaultmoremin, defaultmin, defaultmax, defaultmoremax);
map<string, LimiterPtr> limits;
PropertyDict patterns = properties->getPropertiesForPrefix("Analyzer."+type_+".Patterns");
for (PropertyDict::iterator pattern = patterns.begin(); pattern != patterns.end(); ++pattern) {
vector<string> strings;
boost::algorithm::split(strings, pattern->second, boost::algorithm::is_any_of(" "));
limits[strings.at(0)]=new Limiter(lexical_cast<int>(strings.at(1)),lexical_cast<int>(strings.at(2)),lexical_cast<int>(strings.at(3)),lexical_cast<int>(strings.at(4)));
}
{
RWRecMutex::WLock lock(mutex_);
limits_ = limits;
default_ = defaulter;
}
MCE_DEBUG("Analyzer::reload done");
}
示例3: ex
bool
IceBox::ServiceManagerI::start()
{
try
{
ServiceManagerPtr obj = this;
PropertiesPtr properties = _communicator->getProperties();
//
// Create an object adapter. Services probably should NOT share
// this object adapter, as the endpoint(s) for this object adapter
// will most likely need to be firewalled for security reasons.
//
ObjectAdapterPtr adapter;
if(properties->getProperty("IceBox.ServiceManager.Endpoints") != "")
{
adapter = _communicator->createObjectAdapter("IceBox.ServiceManager");
Identity identity;
identity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
identity.name = "ServiceManager";
adapter->add(obj, identity);
}
//
// Parse the property set with the prefix "IceBox.Service.". These
// properties should have the following format:
//
// IceBox.Service.Foo=entry_point [args]
//
// We parse the service properties specified in IceBox.LoadOrder
// first, then the ones from remaining services.
//
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
PropertyDict::iterator p;
StringSeq loadOrder = properties->getPropertyAsList("IceBox.LoadOrder");
vector<StartServiceInfo> servicesInfo;
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
if(p == services.end())
{
FailureException ex(__FILE__, __LINE__);
ex.reason = "ServiceManager: no service definition for `" + *q + "'";
throw ex;
}
servicesInfo.push_back(StartServiceInfo(*q, p->second, _argv));
services.erase(p);
}
for(p = services.begin(); p != services.end(); ++p)
{
servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv));
}
//
// Check if some services are using the shared communicator in which
// case we create the shared communicator now with a property set which
// is the union of all the service properties (services which are using
// the shared communicator).
//
PropertyDict sharedCommunicatorServices = properties->getPropertiesForPrefix("IceBox.UseSharedCommunicator.");
if(!sharedCommunicatorServices.empty())
{
InitializationData initData;
initData.properties = createServiceProperties("SharedCommunicator");
for(vector<StartServiceInfo>::iterator q = servicesInfo.begin(); q != servicesInfo.end(); ++q)
{
if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + q->name) <= 0)
{
continue;
}
//
// Load the service properties using the shared communicator properties as
// the default properties.
//
PropertiesPtr svcProperties = createProperties(q->args, initData.properties);
//
// Erase properties from the shared communicator which don't exist in the
// service properties (which include the shared communicator properties
// overriden by the service properties).
//
PropertyDict allProps = initData.properties->getPropertiesForPrefix("");
for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
{
if(svcProperties->getProperty(p->first) == "")
{
initData.properties->setProperty(p->first, "");
}
}
//
// Add the service properties to the shared communicator properties.
//
PropertyDict props = svcProperties->getPropertiesForPrefix("");
for(PropertyDict::const_iterator r = props.begin(); r != props.end(); ++r)
{
initData.properties->setProperty(r->first, r->second);
//.........这里部分代码省略.........
示例4: communicator
bool
IceBox::IceBoxService::start(int argc, char* argv[], int& status)
{
// Run through the command line arguments removing all the service
// properties.
vector<string> args = Ice::argsToStringSeq(argc, argv);
PropertiesPtr properties = communicator()->getProperties();
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
for(PropertyDict::const_iterator p = services.begin(); p != services.end(); ++p)
{
string name = p->first.substr(prefix.size());
StringSeq::iterator q = args.begin();
while(q != args.end())
{
if(q->find("--" + name + ".") == 0)
{
q = args.erase(q);
continue;
}
++q;
}
}
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
try
{
args = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
error(e.reason);
usage(argv[0]);
return false;
}
if(opts.isSet("help"))
{
usage(argv[0]);
status = EXIT_SUCCESS;
return false;
}
if(opts.isSet("version"))
{
print(ICE_STRING_VERSION);
status = EXIT_SUCCESS;
return false;
}
if(!args.empty())
{
usage(argv[0]);
return false;
}
_serviceManager = new ServiceManagerI(communicator(), argc, argv);
return _serviceManager->start();
}
示例5: out
void
ServiceI::validateProperties(const string& name, const PropertiesPtr& properties, const LoggerPtr& logger)
{
static const string suffixes[] =
{
"ReplicatedTopicManagerEndpoints",
"ReplicatedPublishEndpoints",
"Nodes.*",
"Transient",
"NodeId",
"Flush.Timeout",
"InstanceName",
"Election.MasterTimeout",
"Election.ElectionTimeout",
"Election.ResponseTimeout",
"Publish.AdapterId",
"Publish.Endpoints",
"Publish.Locator",
"Publish.PublishedEndpoints",
"Publish.RegisterProcess",
"Publish.ReplicaGroupId",
"Publish.Router",
"Publish.ThreadPool.Size",
"Publish.ThreadPool.SizeMax",
"Publish.ThreadPool.SizeWarn",
"Publish.ThreadPool.StackSize",
"Node.AdapterId",
"Node.Endpoints",
"Node.Locator",
"Node.PublishedEndpoints",
"Node.RegisterProcess",
"Node.ReplicaGroupId",
"Node.Router",
"Node.ThreadPool.Size",
"Node.ThreadPool.SizeMax",
"Node.ThreadPool.SizeWarn",
"Node.ThreadPool.StackSize",
"TopicManager.AdapterId",
"TopicManager.Endpoints",
"TopicManager.Locator",
"TopicManager.Proxy",
"TopicManager.Proxy.EndpointSelection",
"TopicManager.Proxy.ConnectionCached",
"TopicManager.Proxy.PreferSecure",
"TopicManager.Proxy.LocatorCacheTimeout",
"TopicManager.Proxy.Locator",
"TopicManager.Proxy.Router",
"TopicManager.Proxy.CollocationOptimization",
"TopicManager.PublishedEndpoints",
"TopicManager.RegisterProcess",
"TopicManager.ReplicaGroupId",
"TopicManager.Router",
"TopicManager.ThreadPool.Size",
"TopicManager.ThreadPool.SizeMax",
"TopicManager.ThreadPool.SizeWarn",
"TopicManager.ThreadPool.StackSize",
"Trace.Election",
"Trace.Replication",
"Trace.Subscriber",
"Trace.Topic",
"Trace.TopicManager",
"Send.Timeout",
"Discard.Interval",
"SQL.DatabaseType",
"SQL.EncodingVersion",
"SQL.HostName",
"SQL.Port",
"SQL.DatabaseName",
"SQL.UserName",
"SQL.Password"
};
vector<string> unknownProps;
string prefix = name + ".";
PropertyDict props = properties->getPropertiesForPrefix(prefix);
for(PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
{
bool valid = false;
for(unsigned int i = 0; i < sizeof(suffixes)/sizeof(*suffixes); ++i)
{
string prop = prefix + suffixes[i];
if(IceUtilInternal::match(p->first, prop))
{
valid = true;
break;
}
}
if(!valid)
{
unknownProps.push_back(p->first);
}
}
if(!unknownProps.empty())
{
Warning out(logger);
out << "found unknown properties for IceStorm service '" << name << "':";
for(vector<string>::const_iterator p = unknownProps.begin(); p != unknownProps.end(); ++p)
{
out << "\n " << *p;
//.........这里部分代码省略.........
示例6: e
void
ServiceI::start(
const string& name,
const CommunicatorPtr& communicator,
const StringSeq& /*args*/)
{
PropertiesPtr properties = communicator->getProperties();
validateProperties(name, properties, communicator->getLogger());
int id = properties->getPropertyAsIntWithDefault(name + ".NodeId", -1);
// If we are using a replicated deployment and if the topic
// manager thread pool max size is not set then ensure it is set
// to some suitably high number. This ensures no deadlocks in the
// replicated case due to call forwarding from replicas to
// coordinators.
if(id != -1 && properties->getProperty(name + ".TopicManager.ThreadPool.SizeMax").empty())
{
properties->setProperty(name + ".TopicManager.ThreadPool.SizeMax", "100");
}
Ice::ObjectAdapterPtr topicAdapter = communicator->createObjectAdapter(name + ".TopicManager");
Ice::ObjectAdapterPtr publishAdapter = communicator->createObjectAdapter(name + ".Publish");
//
// We use the name of the service for the name of the database environment.
//
string instanceName = properties->getPropertyWithDefault(name + ".InstanceName", "IceStorm");
Identity topicManagerId;
topicManagerId.category = instanceName;
topicManagerId.name = "TopicManager";
if(properties->getPropertyAsIntWithDefault(name+ ".Transient", 0) > 0)
{
_instance = new Instance(instanceName, name, communicator, publishAdapter, topicAdapter, 0);
try
{
TransientTopicManagerImplPtr manager = new TransientTopicManagerImpl(_instance);
_managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(manager, topicManagerId));
}
catch(const Ice::Exception& ex)
{
_instance = 0;
LoggerOutputBase s;
s << "exception while starting IceStorm service " << name << ":\n";
s << ex;
IceBox::FailureException e(__FILE__, __LINE__);
e.reason = s.str();
throw e;
}
topicAdapter->activate();
publishAdapter->activate();
return;
}
if(id == -1) // No replication.
{
_instance = new Instance(instanceName, name, communicator, publishAdapter, topicAdapter);
try
{
_manager = new TopicManagerImpl(_instance);
_managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(_manager->getServant(), topicManagerId));
}
catch(const Ice::Exception& ex)
{
_instance = 0;
LoggerOutputBase s;
s << "exception while starting IceStorm service " << name << ":\n";
s << ex;
IceBox::FailureException e(__FILE__, __LINE__);
e.reason = s.str();
throw e;
}
}
else
{
// Here we want to create a map of id -> election node
// proxies.
map<int, NodePrx> nodes;
string topicManagerAdapterId = properties->getProperty(name + ".TopicManager.AdapterId");
// We support two possible deployments. The first is a manual
// deployment, the second is IceGrid.
//
// Here we check for the manual deployment
const string prefix = name + ".Nodes.";
Ice::PropertyDict props = properties->getPropertiesForPrefix(prefix);
if(!props.empty())
{
for(Ice::PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
{
int nodeid = atoi(p->first.substr(prefix.size()).c_str());
nodes[nodeid] = NodePrx::uncheckedCast(communicator->propertyToProxy(p->first));
//.........这里部分代码省略.........
示例7: out
//.........这里部分代码省略.........
Warning out(_instance->initializationData().logger);
out << "`" << property << "=" << properties->getProperty(property)
<< "': cannot set a router on a router; setting ignored";
}
else
{
routerInfo = _instance->routerManager()->get(router);
}
}
property = propertyPrefix + ".CollocationOptimized";
collocationOptimized = properties->getPropertyAsIntWithDefault(property, collocationOptimized) > 0;
property = propertyPrefix + ".ConnectionCached";
cacheConnection = properties->getPropertyAsIntWithDefault(property, cacheConnection) > 0;
property = propertyPrefix + ".PreferSecure";
preferSecure = properties->getPropertyAsIntWithDefault(property, preferSecure) > 0;
property = propertyPrefix + ".EndpointSelection";
if(!properties->getProperty(property).empty())
{
string type = properties->getProperty(property);
if(type == "Random")
{
endpointSelection = Random;
}
else if(type == "Ordered")
{
endpointSelection = Ordered;
}
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
ex.str = "illegal value `" + type + "'; expected `Random' or `Ordered'";
throw ex;
}
}
property = propertyPrefix + ".LocatorCacheTimeout";
string value = properties->getProperty(property);
if(!value.empty())
{
locatorCacheTimeout = properties->getPropertyAsIntWithDefault(property, locatorCacheTimeout);
if(locatorCacheTimeout < -1)
{
locatorCacheTimeout = -1;
Warning out(_instance->initializationData().logger);
out << "invalid value for " << property << "`" << properties->getProperty(property) << "'"
<< ": defaulting to -1";
}
}
property = propertyPrefix + ".InvocationTimeout";
value = properties->getProperty(property);
if(!value.empty())
{
invocationTimeout = properties->getPropertyAsIntWithDefault(property, invocationTimeout);
if(invocationTimeout < 1 && invocationTimeout != -1)
{
invocationTimeout = -1;
Warning out(_instance->initializationData().logger);
out << "invalid value for " << property << "`" << properties->getProperty(property) << "'"
<< ": defaulting to -1";
}
}
property = propertyPrefix + ".Context.";
PropertyDict contexts = properties->getPropertiesForPrefix(property);
for(PropertyDict::const_iterator p = contexts.begin(); p != contexts.end(); ++p)
{
ctx.insert(make_pair(p->first.substr(property.length()), p->second));
}
}
//
// Create new reference
//
return new RoutableReference(_instance,
_communicator,
ident,
facet,
mode,
secure,
protocol,
encoding,
endpoints,
adapterId,
locatorInfo,
routerInfo,
collocationOptimized,
cacheConnection,
preferSecure,
endpointSelection,
locatorCacheTimeout,
invocationTimeout,
ctx);
}
示例8: ex
void
Ice::PluginManagerI::loadPlugins(int& argc, const char* argv[])
{
assert(_communicator);
StringSeq cmdArgs = argsToStringSeq(argc, argv);
const string prefix = "Ice.Plugin.";
PropertiesPtr properties = _communicator->getProperties();
PropertyDict plugins = properties->getPropertiesForPrefix(prefix);
//
// First, load static plugin factories which were setup to load on
// communicator initialization. If a matching plugin property is
// set, we load the plugin with the plugin specification. The
// entryPoint will be ignored but the rest of the plugin
// specification might be used.
//
if(loadOnInitialization)
{
for(vector<string>::const_iterator p = loadOnInitialization->begin(); p != loadOnInitialization->end(); ++p)
{
string property = prefix + *p;
PropertyDict::iterator r = plugins.find(property + ".cpp");
if(r == plugins.end())
{
r = plugins.find(property);
}
else
{
plugins.erase(property);
}
if(r != plugins.end())
{
loadPlugin(*p, r->second, cmdArgs);
plugins.erase(r);
}
else
{
loadPlugin(*p, "", cmdArgs);
}
}
}
//
// Next, load and initialize the plug-ins defined in the property
// set with the prefix "Ice.Plugin.". These properties should have
// the following format:
//
// Ice.Plugin.name[.<language>]=entry_point [args]
//
// If the Ice.PluginLoadOrder property is defined, load the
// specified plug-ins in the specified order, then load any
// remaining plug-ins.
//
StringSeq loadOrder = properties->getPropertyAsList("Ice.PluginLoadOrder");
for(StringSeq::const_iterator p = loadOrder.begin(); p != loadOrder.end(); ++p)
{
string name = *p;
if(findPlugin(name))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "plug-in `" + name + "' already loaded";
throw ex;
}
string property = prefix + name;
PropertyDict::iterator r = plugins.find(property + ".cpp");
if(r == plugins.end())
{
r = plugins.find(property);
}
else
{
plugins.erase(property);
}
if(r != plugins.end())
{
loadPlugin(name, r->second, cmdArgs);
plugins.erase(r);
}
else
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "plug-in `" + name + "' not defined";
throw ex;
}
}
//
// Load any remaining plug-ins that weren't specified in PluginLoadOrder.
//
while(!plugins.empty())
{
PropertyDict::iterator p = plugins.begin();
//.........这里部分代码省略.........
示例9: catch
bool
MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapName,
const MetricsMapFactoryPtr& factory, const ::Ice::LoggerPtr& logger)
{
const string viewPrefix = "IceMX.Metrics." + _name + ".";
const string mapsPrefix = viewPrefix + "Map.";
PropertyDict mapsProps = properties->getPropertiesForPrefix(mapsPrefix);
string mapPrefix;
PropertyDict mapProps;
if(!mapsProps.empty())
{
mapPrefix = mapsPrefix + mapName + ".";
mapProps = properties->getPropertiesForPrefix(mapPrefix);
if(mapProps.empty())
{
// This map isn't configured for this view.
map<string, MetricsMapIPtr>::iterator q = _maps.find(mapName);
if(q != _maps.end())
{
q->second->destroy();
_maps.erase(q);
return true;
}
return false;
}
}
else
{
mapPrefix = viewPrefix;
mapProps = properties->getPropertiesForPrefix(mapPrefix);
}
if(properties->getPropertyAsInt(mapPrefix + "Disabled") > 0)
{
// This map is disabled for this view.
map<string, MetricsMapIPtr>::iterator q = _maps.find(mapName);
if(q != _maps.end())
{
q->second->destroy();
_maps.erase(q);
return true;
}
return false;
}
map<string, MetricsMapIPtr>::iterator q = _maps.find(mapName);
if(q != _maps.end() && q->second->getProperties() == mapProps)
{
return false; // The map configuration didn't change, no need to re-create.
}
if(q != _maps.end())
{
// Destroy the previous map
q->second->destroy();
_maps.erase(q);
}
try
{
_maps.insert(make_pair(mapName, factory->create(mapPrefix, properties)));
}
catch(const std::exception& ex)
{
::Ice::Warning warn(logger);
warn << "unexpected exception while creating metrics map:\n" << ex;
}
catch(const string& msg)
{
::Ice::Warning warn(logger);
warn << msg;
}
return true;
}
示例10: lock
//.........这里部分代码省略.........
//
if(!CryptImportKey(cryptProv, key, outLength, 0, 0, &hKey))
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: error importing key:\n" + lastErrorToString());
}
LocalFree(key);
key = 0;
CryptDestroyKey(hKey);
hKey = 0;
//
// Create a new memory store to place the certificate
//
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, 0, 0);
if(!store)
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: error creating certificate store:\n" + lastErrorToString());
}
addCertificateToStore(certFile, store, &cert);
//
// Associate key & certificate
//
CRYPT_KEY_PROV_INFO keyProvInfo;
memset(&keyProvInfo, 0, sizeof(keyProvInfo));
keyProvInfo.pwszContainerName = const_cast<wchar_t*>(keySetName.c_str());
keyProvInfo.pwszProvName = const_cast<wchar_t*>(MS_DEF_PROV_W);
keyProvInfo.dwProvType = PROV_RSA_FULL;
keyProvInfo.dwKeySpec = AT_KEYEXCHANGE;
if(!CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo))
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: error seting certificate property:\n" + lastErrorToString());
}
_certs.push_back(cert);
_stores.push_back(store);
}
catch(...)
{
if(keyInfo)
{
LocalFree(keyInfo);
}
if(key)
{
LocalFree(key);
}
if(hKey)
{
CryptDestroyKey(hKey);
}
if(cert)
{
CertFreeCertificateContext(cert);
}
if(store)
{
CertCloseStore(store, 0);
}
throw;
}
}
_allCerts.insert(_allCerts.end(), _certs.begin(), _certs.end());
}
const string findPrefix = prefix + "FindCert.";
map<string, string> certProps = properties->getPropertiesForPrefix(findPrefix);
if(!certProps.empty())
{
for(map<string, string>::const_iterator i = certProps.begin(); i != certProps.end(); ++i)
{
const string name = i->first;
const string val = i->second;
if(!val.empty())
{
string storeSpec = name.substr(findPrefix.size());
vector<PCCERT_CONTEXT> certs = findCertificates(name, storeSpec, val, _stores);
_allCerts.insert(_allCerts.end(), certs.begin(), certs.end());
}
}
if(_allCerts.empty())
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: no certificates found");
}
}
_initialized = true;
}