summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-10-05 17:26:44 +0200
committerBenoit Foucher <benoit@zeroc.com>2012-10-05 17:26:44 +0200
commit44c8fc867ecb65daeddc5aa121ccb4baad16007d (patch)
treed778cff1613749c372f612927c0d02086a68ee0a /cpp/src
parentUpdate IceGridGUI requirements in java/README (diff)
downloadice-44c8fc867ecb65daeddc5aa121ccb4baad16007d.tar.bz2
ice-44c8fc867ecb65daeddc5aa121ccb4baad16007d.tar.xz
ice-44c8fc867ecb65daeddc5aa121ccb4baad16007d.zip
Fixed property validations, added C# metrics test
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/MetricsAdminI.cpp59
-rw-r--r--cpp/src/slice2cs/Gen.cpp10
-rw-r--r--cpp/src/slice2java/Gen.cpp2
3 files changed, 36 insertions, 35 deletions
diff --git a/cpp/src/Ice/MetricsAdminI.cpp b/cpp/src/Ice/MetricsAdminI.cpp
index 74b84487842..3e371db2a32 100644
--- a/cpp/src/Ice/MetricsAdminI.cpp
+++ b/cpp/src/Ice/MetricsAdminI.cpp
@@ -26,7 +26,7 @@ using namespace IceMX;
namespace
{
-const string viewSuffixes[] =
+const string suffixes[] =
{
"Disabled",
"GroupBy",
@@ -36,23 +36,15 @@ const string viewSuffixes[] =
"Map.*",
};
-const string mapSuffixes[] =
-{
- "GroupBy",
- "Accept.*",
- "Reject.*",
- "RetainDetached",
-};
-
void
-validateProperties(const string& prefix, const PropertiesPtr& properties, const string* suffixes, int cnt)
+validateProperties(const string& prefix, const PropertiesPtr& properties)
{
vector<string> unknownProps;
PropertyDict props = properties->getPropertiesForPrefix(prefix);
for(PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
{
bool valid = false;
- for(int i = 0; i < cnt; ++i)
+ for(int i = 0; i < sizeof(suffixes) / sizeof(*suffixes); ++i)
{
string prop = prefix + suffixes[i];
if(IceUtilInternal::match(p->first, prop))
@@ -135,6 +127,8 @@ MetricsMapI::MetricsMapI(const std::string& mapPrefix, const PropertiesPtr& prop
_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);
@@ -189,25 +183,6 @@ MetricsMapI::MetricsMapI(const MetricsMapI& map) :
{
}
-void
-MetricsMapI::validateProperties(const string& prefix, const Ice::PropertiesPtr& props, const vector<string>& subMaps)
-{
- if(subMaps.empty())
- {
- ::validateProperties(prefix, props, mapSuffixes, sizeof(mapSuffixes) / sizeof(*mapSuffixes));
- return;
- }
-
- vector<string> suffixes(mapSuffixes, mapSuffixes + sizeof(mapSuffixes) / sizeof(*mapSuffixes));
- for(vector<string>::const_iterator p = subMaps.begin(); p != subMaps.end(); ++p)
- {
- const string suffix = "Map." + *p + ".";
- ::validateProperties(prefix + suffix, props, mapSuffixes, sizeof(mapSuffixes) / sizeof(*mapSuffixes));
- suffixes.push_back(suffix + '*');
- }
- ::validateProperties(prefix, props, &suffixes[0], suffixes.size());
-}
-
const Ice::PropertyDict&
MetricsMapI::getProperties() const
{
@@ -249,8 +224,13 @@ MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapN
if(mapProps.empty())
{
// This map isn't configured for this view.
- _maps.erase(mapName);
- return true;
+ map<string, MetricsMapIPtr>::iterator q = _maps.find(mapName);
+ if(q != _maps.end())
+ {
+ _maps.erase(q);
+ return true;
+ }
+ return false;
}
}
else
@@ -259,6 +239,18 @@ MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapN
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())
+ {
+ _maps.erase(q);
+ return true;
+ }
+ return false;
+ }
+
map<string, MetricsMapIPtr>::iterator q = _maps.find(mapName);
if(q != _maps.end() && q->second->getProperties() == mapProps)
{
@@ -384,8 +376,7 @@ MetricsAdminI::updateViews()
continue; // View already configured.
}
- validateProperties(viewsPrefix + viewName + ".", _properties, viewSuffixes, sizeof(viewSuffixes) /
- sizeof(*viewSuffixes));
+ validateProperties(viewsPrefix + viewName + ".", _properties);
if(_properties->getPropertyAsIntWithDefault(viewsPrefix + viewName + ".Disabled", 0) > 0)
{
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 1671d887252..7554ad7de0b 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -4841,6 +4841,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "Ice.Instrumentation.InvocationObserver observer__ = IceInternal.ObserverHelper.get(this, __";
_out << op->name() << "_name, context__);";
_out << nl << "int cnt__ = 0;";
+ _out << nl << "try";
+ _out << sb;
_out << nl << "while(true)";
_out << sb;
_out << nl << "Ice.ObjectDel_ delBase__ = null;";
@@ -4879,6 +4881,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "handleException__(delBase__, ex__, true, ref cnt__, observer__);";
_out << eb;
_out << eb;
+ _out << eb;
+ _out << nl << "finally";
+ _out << sb;
+ _out << nl << "if(observer__ != null)";
+ _out << sb;
+ _out << nl << "observer__.detach();";
+ _out << eb;
+ _out << eb;
_out << eb;
}
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index b3769e3310d..d0c4be1a61f 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -4368,7 +4368,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "__ctx = _emptyContext;";
out << eb;
out << nl << "final Ice.Instrumentation.InvocationObserver __observer = IceInternal.ObserverHelper.get(this, ";
- out << "\"" << opName << "\");";
+ out << "\"" << opName << "\", __ctx);";
out << nl << "int __cnt = 0;";
out << nl << "try";
out << sb;