本文整理汇总了C++中PropertiesPtr::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertiesPtr::setProperty方法的具体用法?C++ PropertiesPtr::setProperty怎么用?C++ PropertiesPtr::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertiesPtr
的用法示例。
在下文中一共展示了PropertiesPtr::setProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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");
}
}
示例2: 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;
}
示例3: 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));
//.........这里部分代码省略.........
示例4: 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);
}
//.........这里部分代码省略.........
示例5: if
bool
NodeService::startImpl(int argc, char* argv[], int& status)
{
bool nowarn = false;
bool readonly = false;
string initFromReplica;
string desc;
vector<string> targets;
for(int i = 1; i < argc; ++i)
{
if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
{
usage(argv[0]);
status = EXIT_SUCCESS;
return false;
}
else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
print(ICE_STRING_VERSION);
status = EXIT_SUCCESS;
return false;
}
else if(strcmp(argv[i], "--nowarn") == 0)
{
nowarn = true;
}
else if(strcmp(argv[i], "--readonly") == 0)
{
readonly = true;
}
else if(strcmp(argv[i], "--initdb-from-replica") == 0)
{
if(i + 1 >= argc)
{
error("missing replica argument for option `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
initFromReplica = argv[++i];
}
else if(strcmp(argv[i], "--deploy") == 0)
{
if(i + 1 >= argc)
{
error("missing descriptor argument for option `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
desc = argv[++i];
while(i + 1 < argc && argv[++i][0] != '-')
{
targets.push_back(argv[i]);
}
}
else
{
error("invalid option: `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
}
PropertiesPtr properties = communicator()->getProperties();
//
// Disable server idle time. Otherwise, the adapter would be
// shutdown prematurely and the deactivation would fail.
// Deactivation of the node relies on the object adapter
// to be active since it needs to terminate servers.
//
// TODO: implement Ice.ServerIdleTime in the activator
// termination listener instead?
//
properties->setProperty("Ice.ServerIdleTime", "0");
//
// Warn the user that setting Ice.ThreadPool.Server isn't useful.
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
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.
//.........这里部分代码省略.........
示例6: 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())
//.........这里部分代码省略.........
示例7: 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";
}
}
}
//.........这里部分代码省略.........