本文整理汇总了C++中PropertiesPtr::getPropertyWithDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertiesPtr::getPropertyWithDefault方法的具体用法?C++ PropertiesPtr::getPropertyWithDefault怎么用?C++ PropertiesPtr::getPropertyWithDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertiesPtr
的用法示例。
在下文中一共展示了PropertiesPtr::getPropertyWithDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: init
IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFeedbackPtr& feedback) :
_feedback(feedback),
_dataDir(getDataDir(communicator, ".")),
_thorough(getThorough(communicator, 0) > 0),
_chunkSize(getChunkSize(communicator, 100)),
_remove(getRemove(communicator, 1)),
_log(0)
{
const PropertiesPtr properties = communicator->getProperties();
const char* clientProxyProperty = "IcePatch2Client.Proxy";
std::string clientProxy = properties->getProperty(clientProxyProperty);
if(clientProxy.empty())
{
const char* endpointsProperty = "IcePatch2.Endpoints";
string endpoints = properties->getProperty(endpointsProperty);
if(endpoints.empty())
{
ostringstream os;
os << "No proxy to IcePatch2 server. Please set `" << clientProxyProperty
<< "' or `" << endpointsProperty << "'.";
throw os.str();
}
ostringstream os;
os << "The property " << endpointsProperty << " is deprecated, use " << clientProxyProperty << " instead.";
communicator->getLogger()->warning(os.str());
Identity id;
id.category = properties->getPropertyWithDefault("IcePatch2.InstanceName", "IcePatch2");
id.name = "server";
clientProxy = "\"" + communicator->identityToString(id) + "\" :" + endpoints;
}
ObjectPrx serverBase = communicator->stringToProxy(clientProxy);
FileServerPrx server = FileServerPrx::checkedCast(serverBase);
if(!server)
{
throw "proxy `" + clientProxy + "' is not a file server.";
}
init(server);
}
示例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: out
void
Ice::ObjectAdapterI::initialize(const RouterPrx& router)
{
if(_noConfig)
{
_reference = _instance->referenceFactory()->create("dummy -t", "");
return;
}
PropertiesPtr properties = _instance->initializationData().properties;
StringSeq unknownProps;
bool noProps = filterProperties(unknownProps);
//
// Warn about unknown object adapter properties.
//
if(unknownProps.size() != 0 && properties->getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0)
{
Warning out(_instance->initializationData().logger);
out << "found unknown properties for object adapter `" << _name << "':";
for(unsigned int i = 0; i < unknownProps.size(); ++i)
{
out << "\n " << unknownProps[i];
}
}
try
{
//
// Make sure named adapter has some configuration
//
if(router == 0 && noProps)
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "object adapter `" + _name + "' requires configuration";
throw ex;
}
const_cast<string&>(_id) = properties->getProperty(_name + ".AdapterId");
const_cast<string&>(_replicaGroupId) = properties->getProperty(_name + ".ReplicaGroupId");
//
// Setup a reference to be used to get the default proxy options
// when creating new proxies. By default, create twoway proxies.
//
string proxyOptions = properties->getPropertyWithDefault(_name + ".ProxyOptions", "-t");
try
{
_reference = _instance->referenceFactory()->create("dummy " + proxyOptions, "");
}
catch(const ProxyParseException&)
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'";
throw ex;
}
int threadPoolSize = properties->getPropertyAsInt(_name + ".ThreadPool.Size");
int threadPoolSizeMax = properties->getPropertyAsInt(_name + ".ThreadPool.SizeMax");
bool hasPriority = properties->getProperty(_name + ".ThreadPool.ThreadPriority") != "";
//
// Create the per-adapter thread pool, if necessary. This is done before the creation of the incoming
// connection factory as the thread pool is needed during creation for the call to incFdsInUse.
//
if(threadPoolSize > 0 || threadPoolSizeMax > 0 || hasPriority)
{
_threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
}
_hasAcmTimeout = properties->getProperty(_name + ".ACM") != "";
if(_hasAcmTimeout)
{
_acmTimeout = properties->getPropertyAsInt(_name + ".ACM");
_instance->connectionMonitor()->checkIntervalForACM(_acmTimeout);
}
if(!router)
{
const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
_instance->proxyFactory()->propertyToProxy(_name + ".Router"));
}
if(router)
{
_routerInfo = _instance->routerManager()->get(router);
if(_routerInfo)
{
//
// Make sure this router is not already registered with another adapter.
//
if(_routerInfo->getAdapter())
{
throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
_instance->identityToString(router->ice_getIdentity()));
}
//
// Add the router's server proxy endpoints to this object
// adapter.
//
//.........这里部分代码省略.........
示例5: if
void
IceServiceInstaller::install(const PropertiesPtr& properties)
{
_debug = properties->getPropertyAsInt("Debug") != 0;
initializeSid(properties->getPropertyWithDefault("ObjectName", "NT Authority\\LocalService"));
const string defaultDisplayName[] =
{
"IceGrid registry (" + _icegridInstanceName + ")",
"IceGrid node (" + _nodeName + " within " + _icegridInstanceName + ")",
"Glacier2 router (" + _glacier2InstanceName + ")"
};
const string defaultDescription[] =
{
"Location and deployment service for Ice applications",
"Starts and monitors Ice servers",
"Ice Firewall traversal service"
};
string displayName = properties->getPropertyWithDefault("DisplayName", defaultDisplayName[_serviceType]);
string description = properties->getPropertyWithDefault("Description", defaultDescription[_serviceType]);
string imagePath = properties->getProperty("ImagePath");
if(imagePath == "")
{
char buffer[MAX_PATH];
DWORD size = GetModuleFileName(0, buffer, MAX_PATH);
if(size == 0)
{
throw "Can't get full path to self: " + IceUtilInternal::errorToString(GetLastError());
}
imagePath = string(buffer, size);
imagePath.replace(imagePath.rfind('\\'), string::npos, "\\" + serviceTypeToLowerString(_serviceType) + ".exe");
}
else
{
imagePath = fixDirSeparator(imagePath);
}
if(!fileExists(imagePath))
{
throw imagePath + ": not found";
}
string dependency;
if(_serviceType == icegridregistry)
{
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
throw "The IceGrid registry service can't depend on itself";
}
string registryDataDir = fixDirSeparator(_serviceProperties->getProperty("IceGrid.Registry.Data"));
if(registryDataDir == "")
{
throw "IceGrid.Registry.Data must be set in " + _configFile;
}
if(!IceUtilInternal::isAbsolutePath(registryDataDir))
{
throw "'" + registryDataDir + "' is a relative path; IceGrid.Registry.Data must be an absolute path";
}
if(!mkdir(registryDataDir))
{
grantPermissions(registryDataDir, SE_FILE_OBJECT, true, true);
}
}
else if(_serviceType == icegridnode)
{
string nodeDataDir = fixDirSeparator(_serviceProperties->getProperty("IceGrid.Node.Data"));
if(nodeDataDir == "")
{
throw "IceGrid.Node.Data must be set in " + _configFile;
}
if(!IceUtilInternal::isAbsolutePath(nodeDataDir))
{
throw "'" + nodeDataDir + "' is a relative path; IceGrid.Node.Data must be an absolute path";
}
if(!mkdir(nodeDataDir))
{
grantPermissions(nodeDataDir, SE_FILE_OBJECT, true, true);
}
grantPermissions("MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib", SE_REGISTRY_KEY, true);
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
dependency = "icegridregistry." + _icegridInstanceName;
}
}
else if(_serviceType == glacier2router)
{
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
if(_icegridInstanceName == "")
{
throw "Ice.Default.Locator must be set in " + _configFile + " when DependOnRegistry is not zero";
}
//.........这里部分代码省略.........
示例6: ex
Ice::ObjectAdapter::ObjectAdapter(const InstancePtr& instance, const CommunicatorPtr& communicator,
const ObjectAdapterFactoryPtr& objectAdapterFactory,
const string& name, const string& endpointInfo,
#ifdef ICEE_HAS_ROUTER
const RouterPrx& router,
#endif
bool noConfig) :
_deactivated(false),
_instance(instance),
_communicator(communicator),
_objectAdapterFactory(objectAdapterFactory),
_servantManager(new ServantManager(instance, name)),
_activateOneOffDone(false),
_name(name),
#ifdef ICEE_HAS_LOCATOR
_id(instance->initializationData().properties->getProperty(name + ".AdapterId")),
_replicaGroupId(instance->initializationData().properties->getProperty(name + ".ReplicaGroupId")),
#endif
_waitForActivate(false),
_destroying(false),
_destroyed(false),
_noConfig(noConfig)
{
if(_noConfig)
{
_reference = _instance->referenceFactory()->create("dummy -t", "");
return;
}
PropertiesPtr properties = instance->initializationData().properties;
//
// Setup a reference to be used to get the default proxy options
// when creating new proxies. By default, create twoway proxies.
//
string proxyOptions = properties->getPropertyWithDefault(_name + ".ProxyOptions", "-t");
try
{
_reference = _instance->referenceFactory()->create("dummy " + proxyOptions, "");
}
catch(const ProxyParseException&)
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'";
throw ex;
}
__setNoDelete(true);
try
{
#ifdef ICEE_HAS_ROUTER
if(!router)
{
string routerStr = _instance->initializationData().properties->getProperty(_name + ".Router");
if(!routerStr.empty())
{
const_cast<RouterPrx&>(router) =
RouterPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(routerStr));
}
}
if(router)
{
_routerInfo = _instance->routerManager()->get(router);
if(_routerInfo)
{
//
// Make sure this router is not already registered with another adapter.
//
if(_routerInfo->getAdapter())
{
throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
_instance->identityToString(router->ice_getIdentity()));
}
//
// Add the router's server proxy endpoints to this object
// adapter.
//
vector<EndpointPtr> endpoints = _routerInfo->getServerEndpoints();
copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
_routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()),
_routerEndpoints.end());
//
// Associate this object adapter with the router. This way,
// new outgoing connections to the router's client proxy will
// use this object adapter for callbacks.
//
_routerInfo->setAdapter(this);
//
// Also modify all existing outgoing connections to the
// router's client proxy to use this object adapter for
// callbacks.
//
_instance->outgoingConnectionFactory()->setRouterInfo(_routerInfo);
}
}
else
//.........这里部分代码省略.........
示例7: 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));
//.........这里部分代码省略.........
示例8: PluginInitializationException
//.........这里部分代码省略.........
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: key file not found:\n" + keyFile);
}
keyFile = resolved;
}
try
{
_chain.reset(loadCertificateChain(file, keyFile, keychain, keychainPassword, password, passwordPrompt,
passwordRetryMax));
break;
}
catch(const CertificateReadException& ce)
{
//
// If this is the last certificate rethrow the exception as PluginInitializationException,
// otherwise try the next certificate.
//
if(i == files.size() - 1)
{
throw PluginInitializationException(__FILE__, __LINE__, ce.reason);
}
}
}
}
else if(!findCert.empty())
{
_chain.reset(findCertificateChain(keychain, keychainPassword, findCert));
}
//
// DiffieHellmanParams in DER format.
//
#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
string dhFile = properties->getProperty("IceSSL.DHParams");
if(!dhFile.empty())
{
string resolved;
if(!checkPath(dhFile, defaultDir, false, resolved))
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: DH params file not found:\n" + dhFile);
}
readFile(resolved, _dhParams);
}
#endif
//
// Establish the cipher list.
//
const string ciphers = properties->getProperty("IceSSL.Ciphers");
CiphersHelper::initialize();
if(!ciphers.empty())
{
parseCiphers(ciphers);
}
if(securityTraceLevel() >= 1)
{
ostringstream os;
os << "enabling SSL ciphersuites:";
if(_ciphers.empty())
{
map<string, SSLCipherSuite> enabled = CiphersHelper::ciphers();
for(map<string, SSLCipherSuite>::const_iterator i = enabled.begin(); i != enabled.end(); ++i)
{
os << "\n " << i->first;
}
}
else
{
for(vector<SSLCipherSuite>::const_iterator i = _ciphers.begin(); i != _ciphers.end(); ++i)
{
os << "\n " << getCipherName(*i);
}
}
getLogger()->trace(securityTraceCategory(), os.str());
}
//
// Parse protocols
//
const string protocolVersionMax = properties->getProperty("IceSSL.ProtocolVersionMax");
if(!protocolVersionMax.empty())
{
_protocolVersionMax = parseProtocol(protocolVersionMax);
}
//
// The default min protocol version is set to TLS1.0 to avoid security issues with SSLv3
//
const string protocolVersionMin = properties->getPropertyWithDefault("IceSSL.ProtocolVersionMin", "tls1_0");
if(!protocolVersionMin.empty())
{
_protocolVersionMin = parseProtocol(protocolVersionMin);
}
_initialized = true;
}
示例9: if
//.........这里部分代码省略.........
Warning out(communicator()->getLogger());
out << "setting `Ice.ThreadPool.Server.Size' is not useful, ";
out << "you should set individual adapter thread pools instead.";
}
setupThreadPool(properties, "IceGrid.Node.ThreadPool", 1, 100);
//
// Create the activator.
//
TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Node");
_activator = new Activator(traceLevels);
//
// Collocate the IceGrid registry if we need to.
//
if(properties->getPropertyAsInt("IceGrid.Node.CollocateRegistry") > 0)
{
_registry = new CollocatedRegistry(communicator(), _activator, nowarn, readonly, initFromReplica);
if(!_registry->start())
{
return false;
}
//
// Set the default locator property to point to the collocated
// locator (this property is passed by the activator to each
// activated server). The default locator is also needed by
// the node session manager.
//
if(properties->getProperty("Ice.Default.Locator").empty())
{
Identity locatorId;
locatorId.category = properties->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
locatorId.name = "Locator";
string endpoints = properties->getProperty("IceGrid.Registry.Client.Endpoints");
string locPrx = "\"" + communicator()->identityToString(locatorId) + "\" :" + endpoints;
communicator()->setDefaultLocator(Ice::LocatorPrx::uncheckedCast(communicator()->stringToProxy(locPrx)));
properties->setProperty("Ice.Default.Locator", locPrx);
}
}
else if(properties->getProperty("Ice.Default.Locator").empty())
{
error("property `Ice.Default.Locator' is not set");
return false;
}
//
// Initialize the database environment (first setup the directory structure if needed).
//
string dataPath = properties->getProperty("IceGrid.Node.Data");
string dbPath;
if(dataPath.empty())
{
error("property `IceGrid.Node.Data' is not set");
return false;
}
else
{
if(!IceUtilInternal::directoryExists(dataPath))
{
FileException ex(__FILE__, __LINE__);
ex.path = dataPath;
ex.error = IceInternal::getSystemErrno();
ServiceError err(this);
示例10: out
bool
RegistryI::start(bool nowarn)
{
assert(_communicator);
PropertiesPtr properties = _communicator->getProperties();
//
// Initialize the database environment.
//
string dbPath = properties->getProperty("IceGrid.Registry.Data");
if(dbPath.empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Data' is not set";
return false;
}
else
{
struct stat filestat;
if(stat(dbPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
Error out(_communicator->getLogger());
SyscallException ex(__FILE__, __LINE__);
ex.error = getSystemErrno();
out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
return false;
}
}
//
// Check that required properties are set and valid.
//
if(properties->getProperty("IceGrid.Registry.Client.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Client.Endpoints' is not set";
return false;
}
if(properties->getProperty("IceGrid.Registry.Server.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Server.Endpoints' is not set";
return false;
}
if(properties->getProperty("IceGrid.Registry.Internal.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Internal.Endpoints' is not set";
return false;
}
if(!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
if(!nowarn)
{
Warning out(_communicator->getLogger());
out << "session manager endpoints `IceGrid.Registry.SessionManager.Endpoints' enabled";
}
}
properties->setProperty("Ice.PrintProcessId", "0");
properties->setProperty("Ice.ServerIdleTime", "0");
properties->setProperty("IceGrid.Registry.Client.AdapterId", "");
properties->setProperty("IceGrid.Registry.Server.AdapterId", "");
properties->setProperty("IceGrid.Registry.SessionManager.AdapterId", "");
properties->setProperty("IceGrid.Registry.Internal.AdapterId", "");
setupThreadPool(properties, "Ice.ThreadPool.Client", 1, 100);
setupThreadPool(properties, "IceGrid.Registry.Client.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Server.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.SessionManager.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Internal.ThreadPool", 1, 100);
_replicaName = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
_master = _replicaName == "Master";
_sessionTimeout = properties->getPropertyAsIntWithDefault("IceGrid.Registry.SessionTimeout", 30);
//
// Get the instance name
//
if(_master)
{
_instanceName = properties->getProperty("IceGrid.InstanceName");
if(_instanceName.empty())
{
if(_communicator->getDefaultLocator())
{
_instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
}
else
{
_instanceName = "IceGrid";
}
}
}
else
{
if(properties->getProperty("Ice.Default.Locator").empty())
//.........这里部分代码省略.........
示例11: out
bool
RegistryI::startImpl()
{
assert(_communicator);
PropertiesPtr properties = _communicator->getProperties();
//
// Check that required properties are set and valid.
//
if(properties->getProperty("IceGrid.Registry.Client.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Client.Endpoints' is not set";
return false;
}
if(properties->getProperty("IceGrid.Registry.Server.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Server.Endpoints' is not set";
return false;
}
if(properties->getProperty("IceGrid.Registry.Internal.Endpoints").empty())
{
Error out(_communicator->getLogger());
out << "property `IceGrid.Registry.Internal.Endpoints' is not set";
return false;
}
if(!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
if(!_nowarn)
{
Warning out(_communicator->getLogger());
out << "session manager endpoints `IceGrid.Registry.SessionManager.Endpoints' enabled";
if(properties->getPropertyAsInt("IceGrid.Registry.SessionFilters") == 0)
{
out << " (with Glacier2 filters disabled)";
}
}
}
if(!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty())
{
if(!_nowarn)
{
Warning out(_communicator->getLogger());
out << "administrative session manager endpoints `IceGrid.Registry.AdminSessionManager.Endpoints' enabled";
if(properties->getPropertyAsInt("IceGrid.Registry.AdminSessionFilters") == 0)
{
out << " (with Glacier2 filters disabled)";
}
}
}
properties->setProperty("Ice.PrintProcessId", "0");
properties->setProperty("Ice.ServerIdleTime", "0");
properties->setProperty("IceGrid.Registry.Client.AdapterId", "");
properties->setProperty("IceGrid.Registry.Server.AdapterId", "");
properties->setProperty("IceGrid.Registry.SessionManager.AdapterId", "");
properties->setProperty("IceGrid.Registry.Internal.AdapterId", "");
setupThreadPool(properties, "IceGrid.Registry.Client.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Server.ThreadPool", 1, 10, true); // Serialize for admin callbacks
setupThreadPool(properties, "IceGrid.Registry.SessionManager.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Internal.ThreadPool", 1, 100);
_replicaName = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
_master = _replicaName == "Master";
_sessionTimeout = properties->getPropertyAsIntWithDefault("IceGrid.Registry.SessionTimeout", 30);
if(!_master && properties->getProperty("Ice.Default.Locator").empty())
{
if(properties->getProperty("Ice.Default.Locator").empty())
{
Error out(_communicator->getLogger());
out << "property `Ice.Default.Locator' is not set";
return false;
}
}
//
// Get the instance name
//
if(_master)
{
_instanceName = properties->getProperty("IceGrid.InstanceName");
if(_instanceName.empty())
{
if(_communicator->getDefaultLocator())
{
_instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
}
else
{
_instanceName = "IceGrid";
}
}
}
//.........这里部分代码省略.........
示例12: if
IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties) :
overrideTimeout(false),
overrideTimeoutValue(-1),
overrideConnectTimeout(false),
overrideConnectTimeoutValue(-1),
overrideCloseTimeout(false),
overrideCloseTimeoutValue(-1),
overrideCompress(false),
overrideCompressValue(false),
overrideSecure(false),
overrideSecureValue(false)
{
const_cast<string&>(defaultProtocol) = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host");
string value;
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
const_cast<bool&>(overrideTimeout) = true;
const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideConnectTimeout) = true;
const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
}
value = properties->getProperty("Ice.Override.CloseTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideCloseTimeout) = true;
const_cast<Int&>(overrideCloseTimeoutValue) = properties->getPropertyAsInt("Ice.Override.CloseTimeout");
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
const_cast<bool&>(overrideCompress) = true;
const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
const_cast<bool&>(overrideSecure) = true;
const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
}
const_cast<bool&>(defaultCollocationOptimization) =
properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
{
defaultEndpointSelection = Random;
}
else if(value == "Ordered")
{
defaultEndpointSelection = Ordered;
}
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
throw ex;
}
const_cast<int&>(defaultLocatorCacheTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
const_cast<bool&>(defaultPreferSecure) =
properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EncodingVersion", encodingVersionToString(currentEncoding));
defaultEncoding = stringToEncodingVersion(value);
checkSupportedEncoding(defaultEncoding);
bool slicedFormat = properties->getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
const_cast<FormatType&>(defaultFormat) = slicedFormat ? SlicedFormat : CompactFormat;
}
示例13: ex
IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties, const LoggerPtr& logger) :
overrideTimeout(false),
overrideTimeoutValue(-1),
overrideConnectTimeout(false),
overrideConnectTimeoutValue(-1),
overrideCloseTimeout(false),
overrideCloseTimeoutValue(-1),
overrideCompress(false),
overrideCompressValue(false),
overrideSecure(false),
overrideSecureValue(false)
{
const_cast<string&>(defaultProtocol) = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host");
string value;
#ifndef ICE_OS_WINRT
value = properties->getProperty("Ice.Default.SourceAddress");
if(!value.empty())
{
const_cast<Address&>(defaultSourceAddress) = getNumericAddress(value);
if(!isAddressValid(defaultSourceAddress))
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "invalid IP address set for Ice.Default.SourceAddress: `" + value + "'";
throw ex;
}
}
#endif
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
const_cast<bool&>(overrideTimeout) = true;
const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
if(overrideTimeoutValue < 1 && overrideTimeoutValue != -1)
{
const_cast<Int&>(overrideTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.Timeout `" << properties->getProperty("Ice.Override.Timeout")
<< "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideConnectTimeout) = true;
const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
if(overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1)
{
const_cast<Int&>(overrideConnectTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.ConnectTimeout `"
<< properties->getProperty("Ice.Override.ConnectTimeout") << "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.CloseTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideCloseTimeout) = true;
const_cast<Int&>(overrideCloseTimeoutValue) = properties->getPropertyAsInt("Ice.Override.CloseTimeout");
if(overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1)
{
const_cast<Int&>(overrideCloseTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.CloseTimeout `"
<< properties->getProperty("Ice.Override.CloseTimeout") << "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
const_cast<bool&>(overrideCompress) = true;
const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress") > 0;
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
const_cast<bool&>(overrideSecure) = true;
const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure") > 0;
}
const_cast<bool&>(defaultCollocationOptimization) =
properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
{
defaultEndpointSelection = Random;
}
else if(value == "Ordered")
{
defaultEndpointSelection = Ordered;
}
//.........这里部分代码省略.........
示例14: if
int
Client::run(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
vector<string> commands;
try
{
commands = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << e.reason << endl;
usage();
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage();
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
if(commands.empty())
{
usage();
return EXIT_FAILURE;
}
ObjectPrxPtr base = communicator()->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy");
if(base == 0)
{
//
// The old deprecated way to retrieve the service manager proxy
//
PropertiesPtr properties = communicator()->getProperties();
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())
{
cerr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return EXIT_FAILURE;
}
managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" :" + managerEndpoints;
}
else
{
string managerAdapterId = properties->getProperty("IceBox.ServiceManager.AdapterId");
if(managerAdapterId.empty())
{
cerr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return EXIT_FAILURE;
}
managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" @" + managerAdapterId;
}
base = communicator()->stringToProxy(managerProxy);
}
IceBox::ServiceManagerPrxPtr manager = ICE_CHECKED_CAST(IceBox::ServiceManagerPrx, base);
if(!manager)
{
cerr << appName() << ": `" << base << "' is not an IceBox::ServiceManager" << endl;
return EXIT_FAILURE;
}
Ice::SliceChecksumDict serverChecksums = manager->getSliceChecksums();
Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
for(Ice::SliceChecksumDict::const_iterator p = localChecksums.begin(); p != localChecksums.end(); ++p)
{
Ice::SliceChecksumDict::const_iterator q = serverChecksums.find(p->first);
if(q == serverChecksums.end())
{
cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
}
else if(p->second != q->second)
{
cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
}
}
//.........这里部分代码省略.........
示例15: lock
void
SChannelEngine::initialize()
{
Mutex::Lock lock(_mutex);
if(_initialized)
{
return;
}
SSLEngine::initialize();
const string prefix = "IceSSL.";
const PropertiesPtr properties = communicator()->getProperties();
//
// Protocols selects which protocols to enable, by default we only enable TLS1.0
// TLS1.1 and TLS1.2 to avoid security issues with SSLv3
//
vector<string> defaultProtocols;
defaultProtocols.push_back("tls1_0");
defaultProtocols.push_back("tls1_1");
defaultProtocols.push_back("tls1_2");
const_cast<DWORD&>(_protocols) =
parseProtocols(properties->getPropertyAsListWithDefault(prefix + "Protocols", defaultProtocols));
//
// Check for a default directory. We look in this directory for
// files mentioned in the configuration.
//
string defaultDir = properties->getProperty(prefix + "DefaultDir");
int passwordRetryMax = properties->getPropertyAsIntWithDefault(prefix + "PasswordRetryMax", 3);
PasswordPromptPtr passwordPrompt = getPasswordPrompt();
setPassword(properties->getProperty(prefix + "Password"));
string ciphers = properties->getProperty(prefix + "Ciphers");
if(!ciphers.empty())
{
parseCiphers(ciphers);
}
if(securityTraceLevel() >= 1)
{
ostringstream os;
os << "enabling SSL ciphersuites:";
if(_ciphers.empty())
{
for(int i = 0; i < supportedCiphersSize; ++i)
{
os << "\n " << getCipherName(supportedCiphers[i]);
}
}
else
{
for(vector<ALG_ID>::const_iterator i = _ciphers.begin(); i != _ciphers.end(); ++i)
{
os << "\n " << getCipherName(*i);
}
}
getLogger()->trace(securityTraceCategory(), os.str());
}
string certStore = properties->getPropertyWithDefault(prefix + "CertStore", "CurrentUser");
if(certStore != "CurrentUser" && certStore != "LocalMachine")
{
getLogger()->warning("Invalid IceSSL.CertStore value `" + certStore + "' adjusted to `CurrentUser'");
certStore = "CurrentUser";
}
//
// Create trusted CA store with contents of CertAuthFile
//
string caFile = properties->getProperty(prefix + "CertAuthFile");
if(!caFile.empty())
{
_rootStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, 0, 0);
if(!_rootStore)
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: error creating in memory certificate store:\n" + lastErrorToString());
}
if(!checkPath(caFile, defaultDir, false))
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: CA certificate file not found:\n" + caFile);
}
addCertificateToStore(caFile, _rootStore);
//
// Create a chain engine that uses our Trusted Root Store
//
#ifdef __MINGW32__
CertChainEngineConfig config;
memset(&config, 0, sizeof(CertChainEngineConfig));
config.cbSize = sizeof(CertChainEngineConfig);
#else
CERT_CHAIN_ENGINE_CONFIG config;
memset(&config, 0, sizeof(CERT_CHAIN_ENGINE_CONFIG));
//.........这里部分代码省略.........