本文整理汇总了C++中PropertiesPtr::getPropertyAsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertiesPtr::getPropertyAsInt方法的具体用法?C++ PropertiesPtr::getPropertyAsInt怎么用?C++ PropertiesPtr::getPropertyAsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertiesPtr
的用法示例。
在下文中一共展示了PropertiesPtr::getPropertyAsInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PluginInitializationException
void
IceSSL::SSLEngine::initialize()
{
const string propPrefix = "IceSSL.";
const PropertiesPtr properties = communicator()->getProperties();
//
// CheckCertName determines whether we compare the name in a peer's
// certificate against its hostname.
//
_checkCertName = properties->getPropertyAsIntWithDefault(propPrefix + "CheckCertName", 0) > 0;
//
// VerifyDepthMax establishes the maximum length of a peer's certificate
// chain, including the peer's certificate. A value of 0 means there is
// no maximum.
//
_verifyDepthMax = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyDepthMax", 3);
//
// VerifyPeer determines whether certificate validation failures abort a connection.
//
_verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2);
if(_verifyPeer < 0 || _verifyPeer > 2)
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: invalid value for " + propPrefix +
"VerifyPeer");
}
_securityTraceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
_securityTraceCategory = "Security";
}
示例2:
void
IceGrid::setupThreadPool(const PropertiesPtr& properties, const string& name, int size, int sizeMax, bool serialize)
{
if(properties->getPropertyAsIntWithDefault(name + ".Size", 0) < size)
{
ostringstream os;
os << size;
properties->setProperty(name + ".Size", os.str());
}
else
{
size = properties->getPropertyAsInt(name + ".Size");
}
if(sizeMax > 0 && properties->getPropertyAsIntWithDefault(name + ".SizeMax", 0) < sizeMax)
{
if(size >= sizeMax)
{
sizeMax = size * 10;
}
ostringstream os;
os << sizeMax;
properties->setProperty(name + ".SizeMax", os.str());
}
if(serialize)
{
properties->setProperty(name + ".Serialize", "1");
}
}
示例3: createProperties
Ice::PropertiesPtr
IceBox::ServiceManagerI::createServiceProperties(const string& service)
{
PropertiesPtr properties;
PropertiesPtr communicatorProperties = _communicator->getProperties();
if(communicatorProperties->getPropertyAsInt("IceBox.InheritProperties") > 0)
{
properties = communicatorProperties->clone();
properties->setProperty("Ice.Admin.Endpoints", ""); // Inherit all except Ice.Admin.Endpoints!
}
else
{
properties = createProperties();
}
string programName = communicatorProperties->getProperty("Ice.ProgramName");
if(programName.empty())
{
properties->setProperty("Ice.ProgramName", service);
}
else
{
properties->setProperty("Ice.ProgramName", programName + "-" + service);
}
return properties;
}
示例4: network
IceInternal::TraceLevels::TraceLevels(const PropertiesPtr& properties) :
network(0),
networkCat("Network"),
protocol(0),
protocolCat("Protocol"),
retry(0),
retryCat("Retry"),
location(0),
locationCat("Locator"),
slicing(0),
slicingCat("Slicing"),
gc(0),
gcCat("GC"),
threadPool(0),
threadPoolCat("ThreadPool")
{
const string keyBase = "Ice.Trace.";
const_cast<int&>(network) = properties->getPropertyAsInt(keyBase + networkCat);
const_cast<int&>(protocol) = properties->getPropertyAsInt(keyBase + protocolCat);
const_cast<int&>(retry) = properties->getPropertyAsInt(keyBase + retryCat);
const_cast<int&>(location) = properties->getPropertyAsInt(keyBase + locationCat);
const_cast<int&>(slicing) = properties->getPropertyAsInt(keyBase + slicingCat);
const_cast<int&>(gc) = properties->getPropertyAsInt(keyBase + gcCat);
const_cast<int&>(threadPool) = properties->getPropertyAsInt(keyBase + threadPoolCat);
}
示例5: newCallback
IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
_communicator(communicator),
_adminEnabled(false),
_pendingStatusChanges(false),
_traceServiceObserver(0)
{
#ifndef ICE_CPP11_MAPPING
const_cast<CallbackPtr&>(_observerCompletedCB) = newCallback(this, &ServiceManagerI::observerCompleted);
#endif
_logger = _communicator->getLogger();
PropertiesPtr props = _communicator->getProperties();
_traceServiceObserver = props->getPropertyAsInt("IceBox.Trace.ServiceObserver");
if(props->getProperty("Ice.Admin.Enabled") == "")
{
_adminEnabled = props->getProperty("Ice.Admin.Endpoints") != "";
}
else
{
_adminEnabled = props->getPropertyAsInt("Ice.Admin.Enabled") > 0;
}
if(_adminEnabled)
{
StringSeq facetSeq = props->getPropertyAsList("Ice.Admin.Facets");
if(!facetSeq.empty())
{
_adminFacetFilter.insert(facetSeq.begin(), facetSeq.end());
}
}
for(int i = 1; i < argc; i++)
{
_argv.push_back(argv[i]);
}
}
示例6: if
Glacier2::FilterManagerPtr
Glacier2::FilterManager::create(const InstancePtr& instance, const string& userId, const bool allowAddUser)
{
PropertiesPtr props = instance->properties();
string allow = props->getProperty("Glacier2.Filter.Category.Accept");
vector<string> allowSeq;
stringToSeq(allow, allowSeq);
if(allowAddUser)
{
int addUserMode = 0;
if(!props->getProperty("Glacier2.Filter.Category.AcceptUser").empty())
{
addUserMode = props->getPropertyAsInt("Glacier2.Filter.Category.AcceptUser");
}
if(addUserMode > 0 && !userId.empty())
{
if(addUserMode == 1)
{
allowSeq.push_back(userId); // Add user id to allowed categories.
}
else if(addUserMode == 2)
{
allowSeq.push_back('_' + userId); // Add user id with prepended underscore to allowed categories.
}
}
}
Glacier2::StringSetIPtr categoryFilter = new Glacier2::StringSetI(allowSeq);
//
// TODO: refactor initialization of filters.
//
allow = props->getProperty("Glacier2.Filter.AdapterId.Accept");
stringToSeq(allow, allowSeq);
Glacier2::StringSetIPtr adapterIdFilter = new Glacier2::StringSetI(allowSeq);
//
// TODO: Object id's from configurations?
//
IdentitySeq allowIdSeq;
allow = props->getProperty("Glacier2.Filter.Identity.Accept");
stringToSeq(instance->communicator(), allow, allowIdSeq);
Glacier2::IdentitySetIPtr identityFilter = new Glacier2::IdentitySetI(allowIdSeq);
return new Glacier2::FilterManager(instance, categoryFilter, adapterIdFilter, identityFilter);
}
示例7: 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.
//
//.........这里部分代码省略.........
示例8: sync
void
Ice::ObjectAdapterI::activate()
{
LocatorInfoPtr locatorInfo;
bool registerProcess = false;
bool printAdapterReady = false;
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
//
// If some threads are waiting on waitForHold(), we set this
// flag to ensure the threads will start again the wait for
// all the incoming connection factories.
//
_waitForHoldRetry = _waitForHold > 0;
//
// If the one off initializations of the adapter are already
// done, we just need to activate the incoming connection
// factories and we're done.
//
if(_activateOneOffDone)
{
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::activate));
return;
}
//
// One off initializations of the adapter: update the locator
// registry and print the "adapter ready" message. We set the
// _waitForActivate flag to prevent deactivation from other
// threads while these one off initializations are done.
//
_waitForActivate = true;
locatorInfo = _locatorInfo;
if(!_noConfig)
{
PropertiesPtr properties = _instance->initializationData().properties;
printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
registerProcess = properties->getPropertyAsInt(_name + ".RegisterProcess") > 0;
}
}
try
{
Ice::Identity dummy;
dummy.name = "dummy";
updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess);
}
catch(const Ice::LocalException&)
{
//
// If we couldn't update the locator registry, we let the
// exception go through and don't activate the adapter to
// allow to user code to retry activating the adapter
// later.
//
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
_waitForActivate = false;
notifyAll();
}
throw;
}
if(printAdapterReady)
{
cout << _name << " ready" << endl;
}
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
assert(!_deactivated); // Not possible if _waitForActivate = true;
//
// Signal threads waiting for the activation.
//
_waitForActivate = false;
notifyAll();
_activateOneOffDone = true;
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::activate));
}
}
示例9: 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;
}
//.........这里部分代码省略.........
示例10: sync
void
Ice::ObjectAdapterI::activate()
{
LocatorInfoPtr locatorInfo;
bool printAdapterReady = false;
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
//
// If we've previously been initialized we just need to activate the
// incoming connection factories and we're done.
//
if(_state != StateUninitialized)
{
#ifdef ICE_CPP11_MAPPING
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
[](const IncomingConnectionFactoryPtr& factory)
{
factory->activate();
});
#else
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::activate));
#endif
return;
}
//
// One off initializations of the adapter: update the
// locator registry and print the "adapter ready"
// message. We set set state to StateActivating to prevent
// deactivation from other threads while these one off
// initializations are done.
//
_state = StateActivating;
locatorInfo = _locatorInfo;
if(!_noConfig)
{
PropertiesPtr properties = _instance->initializationData().properties;
printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
}
}
try
{
Ice::Identity dummy;
dummy.name = "dummy";
updateLocatorRegistry(locatorInfo, createDirectProxy(dummy));
}
catch(const Ice::LocalException&)
{
//
// If we couldn't update the locator registry, we let the
// exception go through and don't activate the adapter to
// allow to user code to retry activating the adapter
// later.
//
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
_state = StateUninitialized;
notifyAll();
}
throw;
}
if(printAdapterReady)
{
consoleOut << _name << " ready" << endl;
}
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
assert(_state == StateActivating);
#ifdef ICE_CPP11_MAPPING
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
[](const IncomingConnectionFactoryPtr& factory)
{
factory->activate();
});
#else
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::activate));
#endif
_state = StateActive;
notifyAll();
}
}
示例11: out
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
const string& endpointInfo, const RouterPrx& router, bool noConfig) :
_deactivated(false),
_instance(instance),
_communicator(communicator),
_objectAdapterFactory(objectAdapterFactory),
_servantManager(new ServantManager(instance, name)),
_activateOneOffDone(false),
_name(name),
_directCount(0),
_waitForActivate(false),
_destroying(false),
_destroyed(false),
_noConfig(noConfig),
_threadPerConnection(false),
_threadPerConnectionStackSize(0)
{
if(_noConfig)
{
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];
}
}
//
// Make sure named adapter has some configuration
//
if(endpointInfo.empty() && 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");
__setNoDelete(true);
try
{
_threadPerConnection = properties->getPropertyAsInt(_name + ".ThreadPerConnection") > 0;
int threadPoolSize = properties->getPropertyAsInt(_name + ".ThreadPool.Size");
int threadPoolSizeMax = properties->getPropertyAsInt(_name + ".ThreadPool.SizeMax");
if(_threadPerConnection && (threadPoolSize > 0 || threadPoolSizeMax > 0))
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n"
"thread pool and thread per connection";
throw ex;
}
if(!_threadPerConnection && threadPoolSize == 0 && threadPoolSizeMax == 0)
{
_threadPerConnection = _instance->threadPerConnection();
}
if(_threadPerConnection)
{
int stackSize =
properties->getPropertyAsIntWithDefault(_name + ".ThreadPerConnection.StackSize",
static_cast<Int>(_instance->threadPerConnectionStackSize()));
if(stackSize < 0)
{
stackSize = 0;
}
_threadPerConnectionStackSize = stackSize;
}
//
// 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)
{
_threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
}
if(!router)
{
const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
_instance->proxyFactory()->propertyToProxy(_name + ".Router"));
}
if(router)
//.........这里部分代码省略.........
示例12: out
Freeze::MapDb::MapDb(const Ice::CommunicatorPtr& communicator, const string& dbName, const string& keyTypeId, const string& valueTypeId, DbEnv* env) :
Db(env, 0),
_communicator(communicator),
_dbName(dbName),
_key(keyTypeId),
_value(valueTypeId),
_trace(communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Map"))
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "opening Db \"" << _dbName << "\"";
}
try
{
PropertiesPtr properties = _communicator->getProperties();
string propPrefix = "Freeze.Map." + _dbName + ".";
int btreeMinKey = properties->getPropertyAsInt(propPrefix + "BtreeMinKey");
if(btreeMinKey > 2)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s btree minkey to " << btreeMinKey;
}
set_bt_minkey(btreeMinKey);
}
bool checksum = properties->getPropertyAsInt(propPrefix + "Checksum") > 0;
if(checksum)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Turning checksum on for \"" << _dbName << "\"";
}
set_flags(DB_CHKSUM);
}
int pageSize = properties->getPropertyAsInt(propPrefix + "PageSize");
if(pageSize > 0)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s pagesize to " << pageSize;
}
set_pagesize(pageSize);
}
u_int32_t flags = DB_THREAD | DB_CREATE | DB_AUTO_COMMIT;
open(0, Ice::nativeToUTF8(_communicator, _dbName).c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
}
catch(const ::DbException& dx)
{
throw DatabaseException(__FILE__, __LINE__, dx.what());
}
}
示例13: out
IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& prefix, int timeout) :
_instance(instance),
_dispatcher(_instance->initializationData().dispatcher),
_destroyed(false),
_prefix(prefix),
_selector(instance),
_nextThreadId(0),
_size(0),
_sizeIO(0),
_sizeMax(0),
_sizeWarn(0),
_serialize(_instance->initializationData().properties->getPropertyAsInt(_prefix + ".Serialize") > 0),
_hasPriority(false),
_priority(0),
_serverIdleTime(timeout),
_threadIdleTime(0),
_stackSize(0),
_inUse(0),
#if !defined(ICE_USE_IOCP) && !defined(ICE_OS_WINRT)
_inUseIO(0),
_nextHandler(_handlers.end()),
#endif
_promote(true)
{
PropertiesPtr properties = _instance->initializationData().properties;
#ifndef ICE_OS_WINRT
# ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
int nProcessors = sysInfo.dwNumberOfProcessors;
# else
int nProcessors = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
# endif
#endif
//
// We use just one thread as the default. This is the fastest
// possible setting, still allows one level of nesting, and
// doesn't require to make the servants thread safe.
//
int size = properties->getPropertyAsIntWithDefault(_prefix + ".Size", 1);
if(size < 1)
{
Warning out(_instance->initializationData().logger);
out << _prefix << ".Size < 1; Size adjusted to 1";
size = 1;
}
int sizeMax = properties->getPropertyAsIntWithDefault(_prefix + ".SizeMax", size);
#ifndef ICE_OS_WINRT
if(sizeMax == -1)
{
sizeMax = nProcessors;
}
#endif
if(sizeMax < size)
{
Warning out(_instance->initializationData().logger);
out << _prefix << ".SizeMax < " << _prefix << ".Size; SizeMax adjusted to Size (" << size << ")";
sizeMax = size;
}
int sizeWarn = properties->getPropertyAsInt(_prefix + ".SizeWarn");
if(sizeWarn != 0 && sizeWarn < size)
{
Warning out(_instance->initializationData().logger);
out << _prefix << ".SizeWarn < " << _prefix << ".Size; adjusted SizeWarn to Size (" << size << ")";
sizeWarn = size;
}
else if(sizeWarn > sizeMax)
{
Warning out(_instance->initializationData().logger);
out << _prefix << ".SizeWarn > " << _prefix << ".SizeMax; adjusted SizeWarn to SizeMax (" << sizeMax << ")";
sizeWarn = sizeMax;
}
int threadIdleTime = properties->getPropertyAsIntWithDefault(_prefix + ".ThreadIdleTime", 60);
if(threadIdleTime < 0)
{
Warning out(_instance->initializationData().logger);
out << _prefix << ".ThreadIdleTime < 0; ThreadIdleTime adjusted to 0";
threadIdleTime = 0;
}
const_cast<int&>(_size) = size;
const_cast<int&>(_sizeMax) = sizeMax;
const_cast<int&>(_sizeWarn) = sizeWarn;
#ifndef ICE_OS_WINRT
const_cast<int&>(_sizeIO) = min(sizeMax, nProcessors);
#else
const_cast<int&>(_sizeIO) = sizeMax;
#endif
const_cast<int&>(_threadIdleTime) = threadIdleTime;
#ifdef ICE_USE_IOCP
_selector.setup(_sizeIO);
#endif
int stackSize = properties->getPropertyAsInt(_prefix + ".StackSize");
if(stackSize < 0)
//.........这里部分代码省略.........
示例14: 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;
}
示例15: err
bool
RouterService::start(int argc, char* argv[], int& status)
{
bool nowarn;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "nowarn");
vector<string> args;
try
{
args = opts.parse(argc, const_cast<const char**>(argv));
}
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;
}
nowarn = opts.isSet("nowarn");
if(!args.empty())
{
consoleErr << argv[0] << ": too many arguments" << endl;
usage(argv[0]);
return false;
}
PropertiesPtr properties = communicator()->getProperties();
//
// Initialize the client object adapter.
//
const string clientEndpointsProperty = "Glacier2.Client.Endpoints";
if(properties->getProperty(clientEndpointsProperty).empty())
{
error("property `" + clientEndpointsProperty + "' is not set");
return false;
}
if(properties->getPropertyAsInt("Glacier2.SessionTimeout") > 0 &&
properties->getProperty("Glacier2.Client.ACM.Timeout").empty())
{
ostringstream os;
os << properties->getPropertyAsInt("Glacier2.SessionTimeout");
properties->setProperty("Glacier2.Client.ACM.Timeout", os.str());
}
if(properties->getProperty("Glacier2.Client.ACM.Close").empty())
{
properties->setProperty("Glacier2.Client.ACM.Close", "4"); // Forcefull close on invocation and idle.
}
ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapter("Glacier2.Client");
//
// Initialize the server object adapter only if server endpoints
// are defined.
//
const string serverEndpointsProperty = "Glacier2.Server.Endpoints";
ObjectAdapterPtr serverAdapter;
if(!properties->getProperty(serverEndpointsProperty).empty())
{
serverAdapter = communicator()->createObjectAdapter("Glacier2.Server");
}
string instanceName = communicator()->getProperties()->getPropertyWithDefault("Glacier2.InstanceName", "Glacier2");
vector<string> verifierProperties;
verifierProperties.push_back("Glacier2.PermissionsVerifier");
verifierProperties.push_back("Glacier2.SSLPermissionsVerifier");
Glacier2Internal::setupNullPermissionsVerifier(communicator(), instanceName, verifierProperties);
string verifierProperty = verifierProperties[0];
PermissionsVerifierPrx verifier;
ObjectPrx obj;
try
{
//
// We use propertyToProxy instead of stringToProxy because the property
// can provide proxy attributes
//
obj = communicator()->propertyToProxy(verifierProperty);
}
//.........这里部分代码省略.........