diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-09-28 15:16:16 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-09-28 15:16:16 +0200 |
commit | 1d8cbeacf2f29848c845529a9b3f3c1798defeaf (patch) | |
tree | d7d577b650a7837c827b2fdea29d2de9b3cc79c9 /java/src | |
parent | Java & C# port (diff) | |
download | ice-1d8cbeacf2f29848c845529a9b3f3c1798defeaf.tar.bz2 ice-1d8cbeacf2f29848c845529a9b3f3c1798defeaf.tar.xz ice-1d8cbeacf2f29848c845529a9b3f3c1798defeaf.zip |
Added timestamp parameter to getMetricsView, support for metrics in C# and Java IceBox
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceBox/ServiceManagerI.java | 67 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/GraphView.java | 3 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/MetricsView.java | 3 | ||||
-rw-r--r-- | java/src/IceInternal/MetricsAdminI.java | 3 | ||||
-rw-r--r-- | java/src/IceMX/CommunicatorObserverI.java | 60 |
5 files changed, 124 insertions, 12 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index a4893c52061..9d7b830bbb6 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -348,7 +348,29 @@ public class ServiceManagerI extends _ServiceManagerDisp // service.args = initData.properties.parseCommandLineOptions(service.name, service.args); } + + // + // If Ice metrics are enabled on the IceBox communicator, we also enable them on the + // shared communicator. + // + IceInternal.MetricsAdminI metricsAdmin = null; + if(_communicator.getObserver() instanceof IceMX.CommunicatorObserverI) + { + metricsAdmin = new IceInternal.MetricsAdminI(initData.properties, Ice.Util.getProcessLogger()); + initData.observer = new IceMX.CommunicatorObserverI(metricsAdmin); + } + _sharedCommunicator = Ice.Util.initialize(initData); + + // + // Ensure the metrics admin plugin uses the same property set as the + // communicator. This is necessary to correctly deal with runtime + // property updates. + // + if(metricsAdmin != null) + { + metricsAdmin.setProperties(_sharedCommunicator.getProperties()); + } } for(StartServiceInfo s : servicesInfo) @@ -538,10 +560,16 @@ public class ServiceManagerI extends _ServiceManagerDisp // commnunicator property set. // Ice.Communicator communicator; + IceInternal.MetricsAdminI metricsAdmin = null; if(_communicator.getProperties().getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0) { assert(_sharedCommunicator != null); communicator = _sharedCommunicator; + if(communicator.getObserver() instanceof IceMX.CommunicatorObserverI) + { + IceMX.CommunicatorObserverI o = (IceMX.CommunicatorObserverI)communicator.getObserver(); + metricsAdmin = o.getMetricsAdmin(); + } } else { @@ -573,6 +601,16 @@ public class ServiceManagerI extends _ServiceManagerDisp // Clone the logger to assign a new prefix. // initData.logger = _logger.cloneWithPrefix(initData.properties.getProperty("Ice.ProgramName")); + + // + // If Ice metrics are enabled on the IceBox communicator, we also enable them on + // the service communicator. + // + if(_communicator.getObserver() instanceof IceMX.CommunicatorObserverI) + { + metricsAdmin = new IceInternal.MetricsAdminI(initData.properties, initData.logger); + initData.observer = new IceMX.CommunicatorObserverI(metricsAdmin); + } // // Remaining command line options are passed to the communicator. This is @@ -581,6 +619,16 @@ public class ServiceManagerI extends _ServiceManagerDisp info.communicator = Ice.Util.initialize(serviceArgs, initData); info.args = serviceArgs.value; communicator = info.communicator; + + // + // Ensure the metrics admin plugin uses the same property set as the + // communicator. This is necessary to correctly deal with runtime + // property updates. + // + if(metricsAdmin != null) + { + metricsAdmin.setProperties(communicator.getProperties()); + } } catch(Throwable ex) { @@ -600,9 +648,22 @@ public class ServiceManagerI extends _ServiceManagerDisp // in case it wants to set a callback). // final String facetName = "IceBox.Service." + service + ".Properties"; - _communicator.addAdminFacet( - new IceInternal.PropertiesAdminI(facetName, communicator.getProperties(), communicator.getLogger()), - facetName); + IceInternal.PropertiesAdminI propAdmin = new IceInternal.PropertiesAdminI(facetName, + communicator.getProperties(), + communicator.getLogger()); + _communicator.addAdminFacet(propAdmin, facetName); + + // + // If a metrics admin facet is setup for the service, register + // it with the IceBox communicator. + // + if(metricsAdmin != null) + { + _communicator.addAdminFacet(metricsAdmin, "IceBox.Service." + info.name + ".MetricsAdmin"); + + // Ensure the metrics admin facet is notified of property updates. + propAdmin.addUpdateCallback(metricsAdmin); + } // // Instantiate the service. diff --git a/java/src/IceGridGUI/LiveDeployment/GraphView.java b/java/src/IceGridGUI/LiveDeployment/GraphView.java index 58310bf5248..8b818a35987 100644 --- a/java/src/IceGridGUI/LiveDeployment/GraphView.java +++ b/java/src/IceGridGUI/LiveDeployment/GraphView.java @@ -331,7 +331,8 @@ public class GraphView extends JFrame Ice.ObjectPrx admin = _coordinator.getAdmin().ice_identity(adminId); IceMX.Callback_MetricsAdmin_getMetricsView cb = new IceMX.Callback_MetricsAdmin_getMetricsView() { - public void response(final java.util.Map<java.lang.String, IceMX.Metrics[]> data) + public void response(final java.util.Map<java.lang.String, IceMX.Metrics[]> data, + long timestamp) { addData(m, data, System.currentTimeMillis()); } diff --git a/java/src/IceGridGUI/LiveDeployment/MetricsView.java b/java/src/IceGridGUI/LiveDeployment/MetricsView.java index 2b25f47fb69..63de78c90e1 100644 --- a/java/src/IceGridGUI/LiveDeployment/MetricsView.java +++ b/java/src/IceGridGUI/LiveDeployment/MetricsView.java @@ -115,7 +115,8 @@ class MetricsView extends TreeNode IceMX.Callback_MetricsAdmin_getMetricsView cb = new IceMX.Callback_MetricsAdmin_getMetricsView() { - public void response(final java.util.Map<java.lang.String, IceMX.Metrics[]> data) + public void response(final java.util.Map<java.lang.String, IceMX.Metrics[]> data, + long timestamp) { SwingUtilities.invokeLater(new Runnable() { diff --git a/java/src/IceInternal/MetricsAdminI.java b/java/src/IceInternal/MetricsAdminI.java index 80df0eeccf5..de564f9342b 100644 --- a/java/src/IceInternal/MetricsAdminI.java +++ b/java/src/IceInternal/MetricsAdminI.java @@ -180,7 +180,7 @@ public class MetricsAdminI extends IceMX._MetricsAdminDisp implements Ice.Proper } synchronized public java.util.Map<String, IceMX.Metrics[]> - getMetricsView(String viewName, Ice.Current current) + getMetricsView(String viewName, Ice.LongHolder holder, Ice.Current current) throws IceMX.UnknownMetricsView { MetricsViewI view = _views.get(viewName); @@ -188,6 +188,7 @@ public class MetricsAdminI extends IceMX._MetricsAdminDisp implements Ice.Proper { throw new IceMX.UnknownMetricsView(); } + holder.value = IceInternal.Time.currentMonotonicTimeMillis(); return view.getMetrics(); } diff --git a/java/src/IceMX/CommunicatorObserverI.java b/java/src/IceMX/CommunicatorObserverI.java index db1d83f0c90..aef3219181b 100644 --- a/java/src/IceMX/CommunicatorObserverI.java +++ b/java/src/IceMX/CommunicatorObserverI.java @@ -589,7 +589,14 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_connects.isEnabled()) { - return _connects.getObserver(new EndpointHelper(endpt, connector), ObserverI.class); + try + { + return _connects.getObserver(new EndpointHelper(endpt, connector), ObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } } return null; } @@ -599,7 +606,15 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_endpointLookups.isEnabled()) { - return _endpointLookups.getObserver(new EndpointHelper(endpt), ObserverI.class); + try + { + return _endpointLookups.getObserver(new EndpointHelper(endpt), ObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } + } return null; } @@ -610,7 +625,14 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_connections.isEnabled()) { - return _connections.getObserver(new ConnectionHelper(c, e, s), o, ConnectionObserverI.class); + try + { + return _connections.getObserver(new ConnectionHelper(c, e, s), o, ConnectionObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } } return null; } @@ -620,7 +642,14 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_threads.isEnabled()) { - return _threads.getObserver(new ThreadHelper(parent, id, s), o, ThreadObserverI.class); + try + { + return _threads.getObserver(new ThreadHelper(parent, id, s), o, ThreadObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } } return null; } @@ -630,7 +659,14 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_invocations.isEnabled()) { - return _invocations.getObserver(new InvocationHelper(prx, operation, ctx), InvocationObserverI.class); + try + { + return _invocations.getObserver(new InvocationHelper(prx, operation, ctx), InvocationObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } } return null; } @@ -640,7 +676,14 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb { if(_dispatch.isEnabled()) { - return _dispatch.getObserver(new DispatchHelper(c), ObserverI.class); + try + { + return _dispatch.getObserver(new DispatchHelper(c), ObserverI.class); + } + catch(Exception ex) + { + _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex); + } } return null; } @@ -664,6 +707,11 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb }); } + public IceInternal.MetricsAdminI getMetricsAdmin() + { + return _metrics; + } + final private IceInternal.MetricsAdminI _metrics; final private ObserverFactory<ConnectionMetrics, ConnectionObserverI> _connections; final private ObserverFactory<Metrics, ObserverI> _dispatch; |