summaryrefslogtreecommitdiff
path: root/java/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 /java/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 'java/src')
-rw-r--r--java/src/Ice/ConnectionI.java12
-rw-r--r--java/src/IceInternal/MetricsAdminI.java6
-rw-r--r--java/src/IceInternal/MetricsMap.java38
-rw-r--r--java/src/IceInternal/MetricsViewI.java9
-rw-r--r--java/src/IceInternal/Outgoing.java1
-rw-r--r--java/src/IceMX/CommunicatorObserverI.java50
-rw-r--r--java/src/IceMX/InvocationObserverI.java12
-rw-r--r--java/src/IceMX/Observer.java18
-rw-r--r--java/src/IceUtilInternal/StringUtil.java4
9 files changed, 102 insertions, 48 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index 8e0c99e9761..8d7ab93f035 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -265,6 +265,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_observer != null)
{
_observer.attach();
+ _writeStreamPos = -1;
+ _readStreamPos = -1;
}
}
@@ -1842,6 +1844,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_observer != null)
{
_observer.attach();
+ _writeStreamPos = -1;
+ _readStreamPos = -1;
}
}
if(_observer != null && state == StateClosed && _exception != null)
@@ -2606,7 +2610,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
private void
observerStartRead(int pos)
{
- if(_readStreamPos > 0)
+ if(_readStreamPos >= 0)
{
_observer.receivedBytes(pos - _readStreamPos);
}
@@ -2618,13 +2622,13 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
{
assert(pos >= _readStreamPos);
_observer.receivedBytes(pos - _readStreamPos);
- _readStreamPos = 0;
+ _readStreamPos = -1;
}
private void
observerStartWrite(int pos)
{
- if(_writeStreamPos > 0)
+ if(_writeStreamPos >= 0)
{
_observer.sentBytes(pos - _writeStreamPos);
}
@@ -2636,7 +2640,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
{
assert(pos >= _writeStreamPos);
_observer.sentBytes(pos - _writeStreamPos);
- _writeStreamPos = 0;
+ _writeStreamPos = -1;
}
private IceInternal.Incoming
diff --git a/java/src/IceInternal/MetricsAdminI.java b/java/src/IceInternal/MetricsAdminI.java
index de564f9342b..1a7b79065a3 100644
--- a/java/src/IceInternal/MetricsAdminI.java
+++ b/java/src/IceInternal/MetricsAdminI.java
@@ -11,7 +11,7 @@ package IceInternal;
public class MetricsAdminI extends IceMX._MetricsAdminDisp implements Ice.PropertiesAdminUpdateCallback
{
- final static private String[] viewSuffixes =
+ final static private String[] suffixes =
{
"Disabled",
"GroupBy",
@@ -22,7 +22,7 @@ public class MetricsAdminI extends IceMX._MetricsAdminDisp implements Ice.Proper
};
static void
- validateProperties(String prefix, Ice.Properties properties, String[] suffixes)
+ validateProperties(String prefix, Ice.Properties properties)
{
java.util.Map<String, String> props = properties.getPropertiesForPrefix(prefix);
java.util.List<String> unknownProps = new java.util.ArrayList<String>();
@@ -120,7 +120,7 @@ public class MetricsAdminI extends IceMX._MetricsAdminDisp implements Ice.Proper
continue; // View already configured.
}
- validateProperties(viewsPrefix + viewName + ".", _properties, viewSuffixes);
+ validateProperties(viewsPrefix + viewName + ".", _properties);
if(_properties.getPropertyAsIntWithDefault(viewsPrefix + viewName + ".Disabled", 0) > 0)
{
diff --git a/java/src/IceInternal/MetricsMap.java b/java/src/IceInternal/MetricsMap.java
index d1efd1d4bb7..071fea6d326 100644
--- a/java/src/IceInternal/MetricsMap.java
+++ b/java/src/IceInternal/MetricsMap.java
@@ -11,14 +11,6 @@ package IceInternal;
public class MetricsMap<T extends IceMX.Metrics>
{
- final private String[] mapSuffixes =
- {
- "GroupBy",
- "Accept.*",
- "Reject.*",
- "RetainDetached",
- };
-
public class Entry implements Comparable<Entry>
{
Entry(T obj)
@@ -202,6 +194,7 @@ public class MetricsMap<T extends IceMX.Metrics>
MetricsMap(String mapPrefix, Class<T> cl, Ice.Properties props, java.util.Map<String, SubMapFactory<?>> subMaps)
{
+ MetricsAdminI.validateProperties(mapPrefix, props);
_properties = props.getPropertiesForPrefix(mapPrefix);
_retain = props.getPropertyAsIntWithDefault(mapPrefix + "RetainDetached", 10);
@@ -276,7 +269,6 @@ public class MetricsMap<T extends IceMX.Metrics>
_subMaps.put(e.getKey(), e.getValue().createCloneFactory(subMapPrefix, props));
}
- validateProperties(mapPrefix, props, subMapNames);
}
else
{
@@ -296,25 +288,6 @@ public class MetricsMap<T extends IceMX.Metrics>
_subMaps = map._subMaps;
}
- private void
- validateProperties(String prefix, Ice.Properties props, java.util.Collection<String> subMaps)
- {
- if(subMaps.isEmpty())
- {
- MetricsAdminI.validateProperties(prefix, props, mapSuffixes);
- return;
- }
-
- java.util.List<String> suffixes = new java.util.ArrayList<String>(java.util.Arrays.asList(mapSuffixes));
- for(String s : subMaps)
- {
- String suffix = "Map." + s + ".";
- MetricsAdminI.validateProperties(prefix + suffix, props, mapSuffixes);
- suffixes.add(suffix + '*');
- }
- MetricsAdminI.validateProperties(prefix, props, suffixes.toArray(new String[suffixes.size()]));
- }
-
java.util.Map<String, String>
getProperties()
{
@@ -324,6 +297,11 @@ public class MetricsMap<T extends IceMX.Metrics>
synchronized IceMX.Metrics[]
getMetrics()
{
+ if(_objects.isEmpty())
+ {
+ return null;
+ }
+
IceMX.Metrics[] metrics = new IceMX.Metrics[_objects.size()];
int i = 0;
for(Entry e : _objects.values())
@@ -388,10 +366,10 @@ public class MetricsMap<T extends IceMX.Metrics>
return null;
}
}
-
+
for(java.util.Map.Entry<String, java.util.regex.Pattern> e : _reject.entrySet())
{
- if(match(e.getKey(), e.getValue(), helper, false))
+ if(match(e.getKey(), e.getValue(), helper, true))
{
return null;
}
diff --git a/java/src/IceInternal/MetricsViewI.java b/java/src/IceInternal/MetricsViewI.java
index 2eeed91d312..c2486213c26 100644
--- a/java/src/IceInternal/MetricsViewI.java
+++ b/java/src/IceInternal/MetricsViewI.java
@@ -36,8 +36,7 @@ public class MetricsViewI
if(mapProps.isEmpty())
{
// This map isn't configured for this view.
- _maps.remove(mapName);
- return true;
+ return _maps.remove(mapName) != null;
}
}
else
@@ -45,6 +44,12 @@ public class MetricsViewI
mapPrefix = viewPrefix;
mapProps = properties.getPropertiesForPrefix(mapPrefix);
}
+
+ if(properties.getPropertyAsInt(mapPrefix + "Disabled") > 0)
+ {
+ // This map is disabled for this view.
+ return _maps.remove(mapName) != null;
+ }
MetricsMap<?> m = _maps.get(mapName);
if(m != null && m.getProperties().equals(mapProps))
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index 1a047293295..9a4d0fba420 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -41,6 +41,7 @@ public final class Outgoing implements OutgoingMessageCallback
_exception = null;
_sent = false;
_handler = handler;
+ _observer = observer;
_encoding = handler.getReference().getEncoding();
writeHeader(operation, mode, context);
diff --git a/java/src/IceMX/CommunicatorObserverI.java b/java/src/IceMX/CommunicatorObserverI.java
index aef3219181b..678b232bfd2 100644
--- a/java/src/IceMX/CommunicatorObserverI.java
+++ b/java/src/IceMX/CommunicatorObserverI.java
@@ -19,8 +19,8 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
r.add("endpointType", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredMethod("type"));
r.add("endpointIsDatagram", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredMethod("datagram"));
r.add("endpointIsSecure", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredMethod("secure"));
- r.add("endpointProtocolVersion", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredField("protocol"));
- r.add("endpointEncodingVersion", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredField("encoding"));
+ r.add("endpointProtocolVersion", cl.getDeclaredMethod("getEndpointProtocolVersion"));
+ r.add("endpointEncodingVersion", cl.getDeclaredMethod("getEndpointEncodingVersion"));
r.add("endpointTimeout", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredField("timeout"));
r.add("endpointCompress", cl.getDeclaredMethod("getEndpointInfo"), cli.getDeclaredField("compress"));
@@ -161,6 +161,18 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
}
return _endpointInfo;
}
+
+ String
+ getEndpointEncodingVersion()
+ {
+ return Ice.Util.encodingVersionToString(getEndpointInfo().encoding);
+ }
+
+ String
+ getEndpointProtocolVersion()
+ {
+ return Ice.Util.protocolVersionToString(getEndpointInfo().protocol);
+ }
private final Ice.ConnectionInfo _connectionInfo;
private final Ice.Endpoint _endpoint;
@@ -274,6 +286,18 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
return _endpointInfo;
}
+ String
+ getEndpointEncodingVersion()
+ {
+ return Ice.Util.encodingVersionToString(getEndpointInfo().encoding);
+ }
+
+ String
+ getEndpointProtocolVersion()
+ {
+ return Ice.Util.protocolVersionToString(getEndpointInfo().protocol);
+ }
+
Ice.Current
getCurrent()
{
@@ -307,8 +331,7 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
Class<?> cli = Ice.ObjectPrx.class;
add("facet", cl.getDeclaredMethod("getProxy"), cli.getDeclaredMethod("ice_getFacet"));
- add("encoding", cl.getDeclaredMethod("getProxy"),
- cli.getDeclaredMethod("ice_getEncodingVersion"));
+ add("encoding", cl.getDeclaredMethod("getEncodingVersion"));
add("mode", cl.getDeclaredMethod("getMode"));
add("proxy", cl.getDeclaredMethod("getProxy"));
}
@@ -414,7 +437,6 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
{
return _proxy;
}
-
String
getIdentity()
@@ -434,6 +456,12 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
{
return _operation;
}
+
+ String
+ getEncodingVersion()
+ {
+ return Ice.Util.encodingVersionToString(_proxy.ice_getEncodingVersion());
+ }
final private Ice.ObjectPrx _proxy;
final private String _operation;
@@ -532,6 +560,18 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
}
return _endpointInfo;
}
+
+ String
+ getEndpointEncodingVersion()
+ {
+ return Ice.Util.encodingVersionToString(getEndpointInfo().encoding);
+ }
+
+ String
+ getEndpointProtocolVersion()
+ {
+ return Ice.Util.protocolVersionToString(getEndpointInfo().protocol);
+ }
String
getParent()
diff --git a/java/src/IceMX/InvocationObserverI.java b/java/src/IceMX/InvocationObserverI.java
index b581cb1723c..288b0d19730 100644
--- a/java/src/IceMX/InvocationObserverI.java
+++ b/java/src/IceMX/InvocationObserverI.java
@@ -87,7 +87,19 @@ public class InvocationObserverI extends Observer<InvocationMetrics> implements
}
return _endpointInfo;
}
+
+ String
+ getEndpointEncodingVersion()
+ {
+ return Ice.Util.encodingVersionToString(getEndpointInfo().encoding);
+ }
+ String
+ getEndpointProtocolVersion()
+ {
+ return Ice.Util.protocolVersionToString(getEndpointInfo().protocol);
+ }
+
final private Ice.ConnectionInfo _connectionInfo;
final private Ice.Endpoint _endpoint;
private String _id;
diff --git a/java/src/IceMX/Observer.java b/java/src/IceMX/Observer.java
index 0cdc1074b12..4e29fdb255d 100644
--- a/java/src/IceMX/Observer.java
+++ b/java/src/IceMX/Observer.java
@@ -73,14 +73,24 @@ public class Observer<T extends Metrics> extends IceUtilInternal.StopWatch imple
while(p.hasNext())
{
MetricsMap<T>.Entry pe = p.next();
- MetricsMap<T>.Entry qe = q.hasNext() ? q.next() : null;
- if(qe == null || pe.compareTo(qe) < 0) // New metrics object
+ MetricsMap<T>.Entry qe;
+ int comp = 0;
+ if(q.hasNext())
+ {
+ qe = q.next();
+ comp = pe.compareTo(qe);
+ }
+ else
+ {
+ qe = null;
+ }
+
+ if(qe == null || comp < 0) // New metrics object
{
q.add(pe);
- q.previous();
pe.attach(helper);
}
- else if(pe == qe) // Same metrics object
+ else if(comp == 0) // Same metrics object
{
// Nothing to do.
}
diff --git a/java/src/IceUtilInternal/StringUtil.java b/java/src/IceUtilInternal/StringUtil.java
index c990818541b..954c2f63253 100644
--- a/java/src/IceUtilInternal/StringUtil.java
+++ b/java/src/IceUtilInternal/StringUtil.java
@@ -512,6 +512,10 @@ public final class StringUtil
// wildcard. If emptyMatch is true, allow a match of "".
//
int endLength = pat.length() - beginIndex - 1;
+ if(endLength == 0)
+ {
+ return true;
+ }
if(endLength > s.length())
{
return false;