diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-09-14 11:36:49 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-09-14 11:36:49 +0200 |
commit | 4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae (patch) | |
tree | 6021f6dc11029241a65b71c90e78427f1036c759 | |
parent | Fixed metrics tests (diff) | |
download | ice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.tar.bz2 ice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.tar.xz ice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.zip |
Java & C# PropertiesAdmin fixes
-rw-r--r-- | cs/src/Ice/Makefile | 2 | ||||
-rw-r--r-- | cs/src/Ice/Makefile.mak | 2 | ||||
-rw-r--r-- | cs/src/Ice/PropertiesAdminI.cs | 60 | ||||
-rw-r--r-- | java/src/IceInternal/PropertiesAdminI.java | 193 | ||||
-rw-r--r-- | slice/Ice/Metrics.ice | 2 |
5 files changed, 130 insertions, 129 deletions
diff --git a/cs/src/Ice/Makefile b/cs/src/Ice/Makefile index 4c8038b31fe..388a3c89d49 100644 --- a/cs/src/Ice/Makefile +++ b/cs/src/Ice/Makefile @@ -128,7 +128,7 @@ SLICE_SRCS = $(SDIR)/BuiltinSequences.ice \ $(SDIR)/Metrics.ice \ $(SDIR)/ObjectAdapter.ice \ $(SDIR)/ObjectFactory.ice \ - $(SDIR)/Observer.ice \ + $(SDIR)/Instrumentation.ice \ $(SDIR)/Plugin.ice \ $(SDIR)/Process.ice \ $(SDIR)/Properties.ice \ diff --git a/cs/src/Ice/Makefile.mak b/cs/src/Ice/Makefile.mak index 82f69d7a515..e65ab0f172f 100644 --- a/cs/src/Ice/Makefile.mak +++ b/cs/src/Ice/Makefile.mak @@ -129,7 +129,7 @@ GEN_SRCS = $(GDIR)\BuiltinSequences.cs \ $(GDIR)\Metrics.cs \
$(GDIR)\ObjectAdapter.cs \
$(GDIR)\ObjectFactory.cs \
- $(GDIR)\Observer.cs \
+ $(GDIR)\Instrumentation.cs \
$(GDIR)\Plugin.cs \
$(GDIR)\Process.cs \
$(GDIR)\Properties.cs \
diff --git a/cs/src/Ice/PropertiesAdminI.cs b/cs/src/Ice/PropertiesAdminI.cs index c01557afe60..98a1c65fd6d 100644 --- a/cs/src/Ice/PropertiesAdminI.cs +++ b/cs/src/Ice/PropertiesAdminI.cs @@ -52,11 +52,6 @@ namespace IceInternal Dictionary<string, string> props, Ice.Current current) { - Dictionary<string, string> added = new Dictionary<string, string>(); - Dictionary<string, string> changed = new Dictionary<string, string>(); - Dictionary<string, string> removed = new Dictionary<string, string>(); - List<Ice.PropertiesAdminUpdateCallback> callbacks; - lock(this) { Dictionary<string, string> old = _properties.getPropertiesForPrefix(""); @@ -72,6 +67,9 @@ namespace IceInternal // 3) Any properties not present in the new set but present in the existing set. // In other words, the property has been removed. // + Dictionary<string, string> added = new Dictionary<string, string>(); + Dictionary<string, string> changed = new Dictionary<string, string>(); + Dictionary<string, string> removed = new Dictionary<string, string>(); foreach(KeyValuePair<string, string> e in props) { string key = e.Key; @@ -180,35 +178,39 @@ namespace IceInternal _properties.setProperty(e.Key, ""); } - callbacks = new List<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks); - } - - // - // Send the response now so that we do not block the client during the call to the update callback. - // - cb.ice_response(); - - if(callbacks != null) - { - Dictionary<string, string> changes = new Dictionary<string, string>(added); - foreach(KeyValuePair<string, string> e in changed) - { - changes.Add(e.Key, e.Value); - } - foreach(KeyValuePair<string, string> e in removed) - { - changes.Add(e.Key, e.Value); - } + // + // Send the response now so that we do not block the client during the call to the update callback. + // + cb.ice_response(); - foreach(Ice.PropertiesAdminUpdateCallback callback in callbacks) + if(_updateCallbacks.Count > 0) { - try + // + // Copy the callbacks to allow callbacks to update the callbacks. + // + List<Ice.PropertiesAdminUpdateCallback> callbacks = + new List<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks); + + Dictionary<string, string> changes = new Dictionary<string, string>(added); + foreach(KeyValuePair<string, string> e in changed) + { + changes.Add(e.Key, e.Value); + } + foreach(KeyValuePair<string, string> e in removed) { - callback.updated(changes); + changes.Add(e.Key, e.Value); } - catch(System.Exception ex) + + foreach(Ice.PropertiesAdminUpdateCallback callback in callbacks) { - // Ignore. + try + { + callback.updated(changes); + } + catch(System.Exception) + { + // Ignore. + } } } } diff --git a/java/src/IceInternal/PropertiesAdminI.java b/java/src/IceInternal/PropertiesAdminI.java index 59846b5b975..46dbfcd2d59 100644 --- a/java/src/IceInternal/PropertiesAdminI.java +++ b/java/src/IceInternal/PropertiesAdminI.java @@ -30,139 +30,132 @@ public class PropertiesAdminI extends Ice._PropertiesAdminDisp implements Ice.Na return new java.util.TreeMap<String, String>(_properties.getPropertiesForPrefix(name)); } - public void + synchronized public void setProperties_async(Ice.AMD_PropertiesAdmin_setProperties cb, java.util.Map<String, String> props, Ice.Current current) { + java.util.Map<String, String> old = _properties.getPropertiesForPrefix(""); + final int traceLevel = _properties.getPropertyAsInt("Ice.Trace.Admin.Properties"); + + // + // Compute the difference between the new property set and the existing property set: + // + // 1) Any properties in the new set that were not defined in the existing set. + // + // 2) Any properties that appear in both sets but with different values. + // + // 3) Any properties not present in the new set but present in the existing set. + // In other words, the property has been removed. + // java.util.Map<String, String> added = new java.util.HashMap<String, String>(); java.util.Map<String, String> changed = new java.util.HashMap<String, String>(); java.util.Map<String, String> removed = new java.util.HashMap<String, String>(); - java.util.List<Ice.PropertiesAdminUpdateCallback> callbacks = null; - - synchronized(this) + for(java.util.Map.Entry<String, String> e : props.entrySet()) { - java.util.Map<String, String> old = _properties.getPropertiesForPrefix(""); - final int traceLevel = _properties.getPropertyAsInt("Ice.Trace.Admin.Properties"); - - // - // Compute the difference between the new property set and the existing property set: - // - // 1) Any properties in the new set that were not defined in the existing set. - // - // 2) Any properties that appear in both sets but with different values. - // - // 3) Any properties not present in the new set but present in the existing set. - // In other words, the property has been removed. - // - for(java.util.Map.Entry<String, String> e : props.entrySet()) + final String key = e.getKey(); + final String value = e.getValue(); + if(!old.containsKey(key)) { - final String key = e.getKey(); - final String value = e.getValue(); - if(!old.containsKey(key)) + if(value.length() > 0) { - if(value.length() > 0) + // + // This property is new. + // + added.put(key, value); + } + } + else + { + if(!value.equals(old.get(key))) + { + if(value.length() == 0) { // - // This property is new. + // This property was removed. // - added.put(key, value); + removed.put(key, value); } - } - else - { - if(!value.equals(old.get(key))) + else { - if(value.length() == 0) - { - // - // This property was removed. - // - removed.put(key, value); - } - else - { - // - // This property has changed. - // - changed.put(key, value); - } + // + // This property has changed. + // + changed.put(key, value); } - - old.remove(key); } + + old.remove(key); } + } - if(traceLevel > 0 && (!added.isEmpty() || !changed.isEmpty() || !removed.isEmpty())) - { - StringBuilder out = new StringBuilder(128); - out.append("Summary of property changes"); + if(traceLevel > 0 && (!added.isEmpty() || !changed.isEmpty() || !removed.isEmpty())) + { + StringBuilder out = new StringBuilder(128); + out.append("Summary of property changes"); - if(!added.isEmpty()) + if(!added.isEmpty()) + { + out.append("\nNew properties:"); + for(java.util.Map.Entry<String, String> e : added.entrySet()) { - out.append("\nNew properties:"); - for(java.util.Map.Entry<String, String> e : added.entrySet()) + out.append("\n "); + out.append(e.getKey()); + if(traceLevel > 1) { - out.append("\n "); - out.append(e.getKey()); - if(traceLevel > 1) - { - out.append(" = "); - out.append(e.getValue()); - } + out.append(" = "); + out.append(e.getValue()); } } + } - if(!changed.isEmpty()) + if(!changed.isEmpty()) + { + out.append("\nChanged properties:"); + for(java.util.Map.Entry<String, String> e : changed.entrySet()) { - out.append("\nChanged properties:"); - for(java.util.Map.Entry<String, String> e : changed.entrySet()) + out.append("\n "); + out.append(e.getKey()); + if(traceLevel > 1) { - out.append("\n "); - out.append(e.getKey()); - if(traceLevel > 1) - { - out.append(" = "); - out.append(e.getValue()); - out.append(" (old value = "); - out.append(_properties.getProperty(e.getKey())); - out.append(")"); - } + out.append(" = "); + out.append(e.getValue()); + out.append(" (old value = "); + out.append(_properties.getProperty(e.getKey())); + out.append(")"); } } + } - if(!removed.isEmpty()) + if(!removed.isEmpty()) + { + out.append("\nRemoved properties:"); + for(java.util.Map.Entry<String, String> e : removed.entrySet()) { - out.append("\nRemoved properties:"); - for(java.util.Map.Entry<String, String> e : removed.entrySet()) - { - out.append("\n "); - out.append(e.getKey()); - } + out.append("\n "); + out.append(e.getKey()); } - - _logger.trace(_name, out.toString()); } - // - // Update the property set. - // + _logger.trace(_name, out.toString()); + } - for(java.util.Map.Entry<String, String> e : added.entrySet()) - { - _properties.setProperty(e.getKey(), e.getValue()); - } + // + // Update the property set. + // - for(java.util.Map.Entry<String, String> e : changed.entrySet()) - { - _properties.setProperty(e.getKey(), e.getValue()); - } + for(java.util.Map.Entry<String, String> e : added.entrySet()) + { + _properties.setProperty(e.getKey(), e.getValue()); + } - for(java.util.Map.Entry<String, String> e : removed.entrySet()) - { - _properties.setProperty(e.getKey(), ""); - } + for(java.util.Map.Entry<String, String> e : changed.entrySet()) + { + _properties.setProperty(e.getKey(), e.getValue()); + } - callbacks = new java.util.ArrayList<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks); + for(java.util.Map.Entry<String, String> e : removed.entrySet()) + { + _properties.setProperty(e.getKey(), ""); } // @@ -170,8 +163,14 @@ public class PropertiesAdminI extends Ice._PropertiesAdminDisp implements Ice.Na // cb.ice_response(); - if(callbacks != null) + if(!_updateCallbacks.isEmpty()) { + // + // Copy the callbacks to allow callbacks to update the callbacks. + // + java.util.List<Ice.PropertiesAdminUpdateCallback> callbacks = + new java.util.ArrayList<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks); + java.util.Map<String, String> changes = new java.util.HashMap<String, String>(added); changes.putAll(changed); changes.putAll(removed); diff --git a/slice/Ice/Metrics.ice b/slice/Ice/Metrics.ice index b528f59c1e2..8e581ef62c0 100644 --- a/slice/Ice/Metrics.ice +++ b/slice/Ice/Metrics.ice @@ -150,7 +150,7 @@ interface MetricsAdmin /** * - * Get the metrics failure associated for the given metrics + * Get the metrics failure associated for the given metrics. * * @param view The name of the metrics view. * |