diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-11-30 11:01:12 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-11-30 11:01:12 -0500 |
commit | 8844c4b9cc5321fdfb537820fd0c7517756189bd (patch) | |
tree | aab20f66038f27ac96656f6715d10805bd58874c /java/src | |
parent | Fixed various bugs (diff) | |
download | ice-8844c4b9cc5321fdfb537820fd0c7517756189bd.tar.bz2 ice-8844c4b9cc5321fdfb537820fd0c7517756189bd.tar.xz ice-8844c4b9cc5321fdfb537820fd0c7517756189bd.zip |
Implemented service observers
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceBox/ServiceManagerI.java | 199 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Coordinator.java | 17 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveActions.java | 4 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Node.java | 1 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Server.java | 269 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Service.java | 172 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/ServiceEditor.java | 50 | ||||
-rwxr-xr-x | java/src/IceGridGUI/SessionKeeper.java | 138 | ||||
-rw-r--r-- | java/src/IceInternal/PropertyNames.java | 44 |
9 files changed, 754 insertions, 140 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index 686f27596bc..134425e06b6 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -21,6 +21,7 @@ public class ServiceManagerI extends _ServiceManagerDisp _server = server; _logger = _server.communicator().getLogger(); _argv = args; + _traceServiceObserver = _server.communicator().getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver"); } public java.util.Map @@ -64,6 +65,13 @@ public class ServiceManagerI extends _ServiceManagerDisp sw.toString()); } + if(info.active) + { + java.util.List<String> services = new java.util.Vector<String>(); + services.add(name); + servicesStarted(services); + } + return; } } @@ -105,6 +113,13 @@ public class ServiceManagerI extends _ServiceManagerDisp sw.toString()); } + if(!info.active) + { + java.util.List<String> services = new java.util.Vector<String>(); + services.add(name); + servicesStopped(services); + } + return; } } @@ -112,6 +127,65 @@ public class ServiceManagerI extends _ServiceManagerDisp throw new NoSuchServiceException(); } + public synchronized void + addObserver(final ServiceObserverPrx observer, Ice.Current current) + { + // + // Null observers and duplicate registrations are ignored + // + + if(observer != null && _observers.add(observer)) + { + if(_traceServiceObserver >= 1) + { + _logger.trace("IceBox.ServiceObserver", + "Added service observer: " + _server.communicator().proxyToString(observer)); + } + + java.util.List<String> activeServices = new java.util.LinkedList<String>(); + + for(ServiceInfo info: _services) + { + if(info.active) + { + activeServices.add(info.name); + } + } + + if(activeServices.size() > 0) + { + AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted() + { + public void ice_response() + { + // ok, success + } + + public void ice_exception(Ice.LocalException ex) + { + // + // Drop this observer + // + removeObserver(observer, ex); + } + }; + + + try + { + observer.servicesStarted_async(cb, activeServices.toArray(new String[0])); + } + catch(RuntimeException ex) + { + _observers.remove(observer); + observerRemoved(observer, ex); + throw ex; + } + } + } + } + + public void shutdown(Ice.Current current) { @@ -293,6 +367,7 @@ public class ServiceManagerI extends _ServiceManagerDisp return 0; } + private void load(String name, String value) throws FailureException @@ -492,6 +567,13 @@ public class ServiceManagerI extends _ServiceManagerDisp info.args = serviceArgs.value; info.service.start(service, communicator, info.args); info.active = true; + + // + // There is no need to notify the observers since the 'start all' + // (that indirectly calls this method) occurs before the creation of + // the Server Admin object, and before the activation of the main + // object adapter (so before any observer can be registered) + // } catch(Throwable ex) { @@ -554,6 +636,8 @@ public class ServiceManagerI extends _ServiceManagerDisp synchronized private void stopAll() { + java.util.List<String> stoppedServices = new java.util.Vector<String>(); + // // First, for each service, we call stop on the service and flush its database environment to // the disk. Services are stopped in the reverse order of the order they were started. @@ -568,6 +652,7 @@ public class ServiceManagerI extends _ServiceManagerDisp { info.service.stop(); info.active = false; + stoppedServices.add(info.name); } catch(java.lang.Exception e) { @@ -620,9 +705,118 @@ public class ServiceManagerI extends _ServiceManagerDisp } } + servicesStopped(stoppedServices); + _services.clear(); } + + private void + servicesStarted(java.util.List<String> services) + { + assert Thread.holdsLock(this); + + if(services.size() > 0) + { + String[] servicesArray = services.toArray(new String[0]); + + java.util.Iterator<ServiceObserverPrx> p = _observers.iterator(); + while(p.hasNext()) + { + final ServiceObserverPrx observer = p.next(); + + AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted() + { + public void ice_response() + { + // ok, success + } + + public void ice_exception(Ice.LocalException ex) + { + // + // Drop this observer + // + removeObserver(observer, ex); + } + }; + + try + { + observer.servicesStarted_async(cb, servicesArray); + } + catch(RuntimeException ex) + { + p.remove(); + observerRemoved(observer, ex); + } + } + } + } + + private void + servicesStopped(java.util.List<String> services) + { + assert Thread.holdsLock(this); + + if(services.size() > 0) + { + String[] servicesArray = services.toArray(new String[0]); + + java.util.Iterator<ServiceObserverPrx> p = _observers.iterator(); + while(p.hasNext()) + { + final ServiceObserverPrx observer = p.next(); + + AMI_ServiceObserver_servicesStopped cb = new AMI_ServiceObserver_servicesStopped() + { + public void ice_response() + { + // ok, success + } + + public void ice_exception(Ice.LocalException ex) + { + // + // Drop this observer + // + removeObserver(observer, ex); + } + }; + + try + { + observer.servicesStopped_async(cb, servicesArray); + } + catch(RuntimeException ex) + { + p.remove(); + observerRemoved(observer, ex); + } + } + } + } + + private synchronized void + removeObserver(ServiceObserverPrx observer, Ice.LocalException ex) + { + if(_observers.remove(observer)) + { + observerRemoved(observer, ex); + } + } + + private void + observerRemoved(ServiceObserverPrx observer, RuntimeException ex) + { + if(_traceServiceObserver >= 1) + { + _logger.trace("IceBox.ServiceObserver", + "Removed service observer: " + _server.communicator().proxyToString(observer) + + "\nafter catching " + ex.toString()); + } + } + class ServiceInfo { public String name; @@ -635,5 +829,8 @@ public class ServiceManagerI extends _ServiceManagerDisp private Ice.Application _server; private Ice.Logger _logger; private String[] _argv; // Filtered server argument vector - private java.util.List _services = new java.util.LinkedList(); + private java.util.List<ServiceInfo> _services = new java.util.LinkedList<ServiceInfo>(); + + java.util.Set<ServiceObserverPrx> _observers = new java.util.HashSet<ServiceObserverPrx>(); + int _traceServiceObserver = 0; } diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index 85e6ebe38c4..b229ea91183 100755 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -1578,6 +1578,21 @@ public class Coordinator return _sessionKeeper.getAdmin(); } + public String getServerAdminCategory() + { + return _sessionKeeper.getServerAdminCategory(); + } + + public Ice.ObjectPrx addCallback(Ice.Object servant, String name, String facet) + { + return _sessionKeeper.addCallback(servant, name, facet); + } + + public Ice.Object removeCallback(String name, String facet) + { + return _sessionKeeper.removeCallback(name, facet); + } + public StatusBar getStatusBar() { return _statusBar; @@ -2309,7 +2324,7 @@ public class Coordinator _mainFrame.getContentPane().add(_mainPane, BorderLayout.CENTER); } - JComponent getLiveDeploymentPane() + public LiveDeploymentPane getLiveDeploymentPane() { return _liveDeploymentPane; } diff --git a/java/src/IceGridGUI/LiveActions.java b/java/src/IceGridGUI/LiveActions.java index 0a66db5911b..6fa2ad0bb40 100755 --- a/java/src/IceGridGUI/LiveActions.java +++ b/java/src/IceGridGUI/LiveActions.java @@ -76,7 +76,7 @@ public class LiveActions } }; _array[TreeNode.START].putValue(Action.SHORT_DESCRIPTION, - "Start this server"); + "Start this server or service"); _array[TreeNode.STOP] = new AbstractAction( "Stop", Utils.getIcon("/icons/16x16/stop.png")) @@ -87,7 +87,7 @@ public class LiveActions } }; _array[TreeNode.STOP].putValue(Action.SHORT_DESCRIPTION, - "Stop this server"); + "Stop this server or service"); _array[TreeNode.ENABLE] = new AbstractAction( diff --git a/java/src/IceGridGUI/LiveDeployment/Node.java b/java/src/IceGridGUI/LiveDeployment/Node.java index ca2e4422e2c..a9f9484bb26 100755 --- a/java/src/IceGridGUI/LiveDeployment/Node.java +++ b/java/src/IceGridGUI/LiveDeployment/Node.java @@ -393,6 +393,7 @@ class Node extends ListTreeNode } else { + server.removeCallbacks(); removeDescriptor(nodeDesc, server); int index = getIndex(server); _children.remove(server); diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index 2d6e9701d28..ecd00d6bf01 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -139,7 +139,7 @@ class Server extends ListArrayTreeNode { getCoordinator().getMainFrame().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().stopServer_async(cb, _id); + getCoordinator().getAdmin().stopServer_async(cb, _id); } catch(Ice.LocalException e) { @@ -359,9 +359,9 @@ class Server extends ListArrayTreeNode { getCoordinator().getMainFrame().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin(). - patchServer_async(cb, _id, - shutdown == JOptionPane.YES_OPTION); + getCoordinator().getAdmin(). + patchServer_async(cb, _id, + shutdown == JOptionPane.YES_OPTION); } catch(Ice.LocalException e) { @@ -377,7 +377,7 @@ class Server extends ListArrayTreeNode private void enableServer(boolean enable) { final String prefix = (enable ? - "Enabling" : "Disabling") + " server '" + _id + "'..."; + "Enabling" : "Disabling") + " server '" + _id + "'..."; final String action = enable ? "enable" : "disable"; @@ -408,7 +408,7 @@ class Server extends ListArrayTreeNode { getCoordinator().getMainFrame().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().enableServer_async(cb, _id, enable); + getCoordinator().getAdmin().enableServer_async(cb, _id, enable); } catch(Ice.LocalException e) { @@ -423,74 +423,61 @@ class Server extends ListArrayTreeNode public void showRuntimeProperties() { - Ice.AMI_PropertiesAdmin_getPropertiesForPrefix cb = new Ice.AMI_PropertiesAdmin_getPropertiesForPrefix() - { - public void ice_response(final java.util.Map properties) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - _editor.setRuntimeProperties((java.util.SortedMap)properties, Server.this); - } - }); - } - - public void ice_exception(final Ice.LocalException e) + Ice.ObjectPrx serverAdmin = getServerAdmin(); + + if(serverAdmin == null) + { + _editor.setBuildId("", this); + } + else + { + Ice.AMI_PropertiesAdmin_getPropertiesForPrefix cb = new Ice.AMI_PropertiesAdmin_getPropertiesForPrefix() { - SwingUtilities.invokeLater(new Runnable() - { - public void run() + public void ice_response(final java.util.Map properties) + { + SwingUtilities.invokeLater(new Runnable() { - if(e instanceof Ice.ObjectNotExistException) - { - _editor.setBuildId("Error: can't reach this server's Admin object", Server.this); - } - else if(e instanceof Ice.FacetNotExistException) + public void run() { - _editor.setBuildId("Error: this server's Admin object does not provide a 'Properties' facet", - Server.this); + _editor.setRuntimeProperties((java.util.SortedMap)properties, Server.this); } - else + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() { - _editor.setBuildId("Error: " + e.toString(), Server.this); + if(e instanceof Ice.ObjectNotExistException) + { + _editor.setBuildId("Error: can't reach this server's Admin object", Server.this); + } + else if(e instanceof Ice.FacetNotExistException) + { + _editor.setBuildId("Error: this server's Admin object does not provide a 'Properties' facet", + Server.this); + } + else + { + _editor.setBuildId("Error: " + e.toString(), Server.this); + } } - } - }); - } - }; + }); + } + }; - try - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - IceGrid.AdminPrx admin = getCoordinator().getAdmin(); - - if(admin == null) - { - _editor.setBuildId("", this); - } - else - { - // - // Build serverAdmin object - // - Ice.Identity adminId = new Ice.Identity(_id, getRoot().getInstanceName() + "-RegistryRouter"); - Ice.ObjectPrx serverAdmin = admin.ice_identity(adminId); + try + { Ice.PropertiesAdminPrx propAdmin = Ice.PropertiesAdminPrxHelper.uncheckedCast(serverAdmin.ice_facet("Properties")); propAdmin.getPropertiesForPrefix_async(cb, ""); } - } - catch(Ice.LocalException e) - { - _editor.setBuildId("Error: " + e.toString(), this); - } - finally - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + catch(Ice.LocalException e) + { + _editor.setBuildId("Error: " + e.toString(), this); + } } } @@ -546,13 +533,13 @@ class Server extends ListArrayTreeNode } public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { if(_cellRenderer == null) { @@ -700,6 +687,11 @@ class Server extends ListArrayTreeNode { return _state; } + + boolean hasServiceObserver() + { + return _serviceObserver != null; + } int getPid() { @@ -716,6 +708,15 @@ class Server extends ListArrayTreeNode return _resolver; } + void removeCallbacks() + { + if(_serviceObserver != null) + { + getCoordinator().removeCallback(_serviceObserver.ice_getIdentity().name, _serviceObserver.ice_getFacet()); + _serviceObserver = null; + } + } + void rebuild(Server server) { _resolver = server._resolver; @@ -794,6 +795,110 @@ class Server extends ListArrayTreeNode _stateIconIndex = _state.value() + 1; } + if(_serverDescriptor instanceof IceBoxDescriptor) + { + if(_state == ServerState.Active) + { + if(_serviceObserver == null) + { + IceBox.ServiceObserver servant = new IceBox._ServiceObserverDisp() + { + public void servicesStarted(final String[] services, Ice.Current current) + { + final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); + + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + for(Service service: _services) + { + if(serviceSet.contains(service.getId())) + { + service.started(); + } + } + getCoordinator().getLiveDeploymentPane().refresh(); + } + }); + } + + public void servicesStopped(final String[] services, Ice.Current current) + { + final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); + + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + for(Service service: _services) + { + if(serviceSet.contains(service.getId())) + { + service.stopped(); + } + } + getCoordinator().getLiveDeploymentPane().refresh(); + } + }); + } + + }; + + _serviceObserver = IceBox.ServiceObserverPrxHelper.uncheckedCast( + getCoordinator().addCallback(servant, _id, "IceBox.ServiceManager")); + + if(_serviceObserver == null) + { + // TODO: log/report condition (observer not available, e.g. adapter not configured) + } + } + + if(_serviceObserver != null) + { + // + // Add observer to service manager using AMI call + // + + IceBox.AMI_ServiceManager_addObserver cb = new IceBox.AMI_ServiceManager_addObserver() + { + public void ice_response() + { + // all is good + } + + public void ice_exception(Ice.LocalException e) + { + // TODO: log/report exception + } + }; + + Ice.ObjectPrx serverAdmin = getServerAdmin(); + if(serverAdmin != null) + { + IceBox.ServiceManagerPrx serviceManager = + IceBox.ServiceManagerPrxHelper.uncheckedCast(serverAdmin.ice_facet("IceBox.ServiceManager")); + + try + { + serviceManager.addObserver_async(cb, _serviceObserver); + } + catch(Ice.LocalException ex) + { + // TODO: log/report exception + } + } + } + } + else if(_state == null || _state == ServerState.Inactive) + { + for(Service service: _services) + { + service.stopped(); + } + } + } + if(fireEvent) { getRoot().getTreeModel().nodeChanged(this); @@ -986,6 +1091,26 @@ class Server extends ListArrayTreeNode _services.add(new Service(this, serviceName, serviceResolver, descriptor, serviceDescriptor, serverInstancePSDescriptor)); } + + Ice.ObjectPrx getServerAdmin() + { + if(_state != ServerState.Active) + { + return null; + } + + AdminPrx admin = getCoordinator().getAdmin(); + if(admin == null) + { + return null; + } + else + { + Ice.Identity adminId = new Ice.Identity(_id, getCoordinator().getServerAdminCategory()); + return admin.ice_identity(adminId); + } + } + static private String toolTip(ServerState state, int pid, boolean enabled) { @@ -1013,7 +1138,7 @@ class Server extends ListArrayTreeNode private Utils.Resolver _resolver; private java.util.List _adapters = new java.util.LinkedList(); private java.util.List _dbEnvs = new java.util.LinkedList(); - private java.util.List _services = new java.util.LinkedList(); + private java.util.List<Service> _services = new java.util.LinkedList<Service>(); private ServerState _state; private boolean _enabled; @@ -1021,6 +1146,8 @@ class Server extends ListArrayTreeNode private int _pid; private String _toolTip; + private IceBox.ServiceObserverPrx _serviceObserver; + static private DefaultTreeCellRenderer _cellRenderer; static private Icon[][][] _icons; diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java index 5e665714388..b6ee324a0ec 100755 --- a/java/src/IceGridGUI/LiveDeployment/Service.java +++ b/java/src/IceGridGUI/LiveDeployment/Service.java @@ -9,6 +9,7 @@ package IceGridGUI.LiveDeployment; import java.awt.Component; +import javax.swing.Icon; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTree; @@ -29,13 +30,132 @@ class Service extends ListArrayTreeNode { boolean[] actions = new boolean[ACTION_COUNT]; - if(((Server)_parent).getState() != null) + ServerState serverState = ((Server)_parent).getState(); + + if(serverState != null) { actions[RETRIEVE_LOG] = _serviceDescriptor.logs.length > 0; } + if(serverState == ServerState.Active) + { + if(((Server)_parent).hasServiceObserver()) + { + actions[START] = !_started; + actions[STOP] = _started; + } + else + { + actions[START] = true; + actions[STOP] = true; + } + } + return actions; } + public void start() + { + Ice.ObjectPrx serverAdmin = ((Server)_parent).getServerAdmin(); + + if(serverAdmin != null) + { + final String prefix = "Starting service '" + _id + "'..."; + getCoordinator().getStatusBar().setText(prefix); + + IceBox.AMI_ServiceManager_startService cb = new IceBox.AMI_ServiceManager_startService() + { + // + // Called by another thread! + // + public void ice_response() + { + amiSuccess(prefix); + } + + public void ice_exception(Ice.UserException e) + { + if(e instanceof IceBox.AlreadyStartedException) + { + amiSuccess(prefix); + } + else + { + amiFailure(prefix, "Failed to start service " + _id, e.toString()); + } + } + + public void ice_exception(Ice.LocalException e) + { + amiFailure(prefix, "Failed to start service " + _id, e.toString()); + } + }; + + IceBox.ServiceManagerPrx serviceManager = IceBox.ServiceManagerPrxHelper. + uncheckedCast(serverAdmin.ice_facet("IceBox.ServiceManager")); + + try + { + serviceManager.startService_async(cb, _id); + } + catch(Ice.LocalException e) + { + failure(prefix, "Failed to start service " + _id, e.toString()); + } + } + } + + public void stop() + { + Ice.ObjectPrx serverAdmin = ((Server)_parent).getServerAdmin(); + + if(serverAdmin != null) + { + final String prefix = "Stopping service '" + _id + "'..."; + getCoordinator().getStatusBar().setText(prefix); + + IceBox.AMI_ServiceManager_stopService cb = new IceBox.AMI_ServiceManager_stopService() + { + // + // Called by another thread! + // + public void ice_response() + { + amiSuccess(prefix); + } + + public void ice_exception(Ice.UserException e) + { + if(e instanceof IceBox.AlreadyStoppedException) + { + amiSuccess(prefix); + } + else + { + amiFailure(prefix, "Failed to stop service " + _id, e.toString()); + } + } + + public void ice_exception(Ice.LocalException e) + { + amiFailure(prefix, "Failed to stop service " + _id, e.toString()); + } + }; + + IceBox.ServiceManagerPrx serviceManager = IceBox.ServiceManagerPrxHelper. + uncheckedCast(serverAdmin.ice_facet("IceBox.ServiceManager")); + + try + { + serviceManager.stopService_async(cb, _id); + } + catch(Ice.LocalException e) + { + failure(prefix, "Failed to stop service " + _id, e.toString()); + } + } + } + + public void retrieveLog() { assert _serviceDescriptor.logs.length > 0; @@ -107,13 +227,23 @@ class Service extends ListArrayTreeNode if(_cellRenderer == null) { _cellRenderer = new DefaultTreeCellRenderer(); - _cellRenderer.setOpenIcon( - Utils.getIcon("/icons/16x16/service.png")); - _cellRenderer.setClosedIcon( - Utils.getIcon("/icons/16x16/service.png")); + _startedIcon = Utils.getIcon("/icons/16x16/service_started.png"); + _stoppedIcon = Utils.getIcon("/icons/16x16/service.png"); + } + + Icon icon = _started ? _startedIcon : _stoppedIcon; + + if(expanded) + { + _cellRenderer.setOpenIcon(icon); + } + else + { + _cellRenderer.setClosedIcon(icon); } + return _cellRenderer.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); } @@ -122,7 +252,7 @@ class Service extends ListArrayTreeNode { if(_editor == null) { - _editor = new ServiceEditor(); + _editor = new ServiceEditor(getCoordinator()); } _editor.show(this); return _editor; @@ -135,6 +265,9 @@ class Service extends ListArrayTreeNode if(_popup == null) { _popup = new JPopupMenu(); + _popup.add(la.get(START)); + _popup.add(la.get(STOP)); + _popup.addSeparator(); _popup.add(la.get(RETRIEVE_LOG)); } @@ -201,6 +334,29 @@ class Service extends ListArrayTreeNode } } + boolean isStarted() + { + return _started; + } + + void started() + { + if(!_started) + { + _started = true; + getRoot().getTreeModel().nodeChanged(this); + } + } + + void stopped() + { + if(_started) + { + _started = false; + getRoot().getTreeModel().nodeChanged(this); + } + } + Utils.Resolver getResolver() { return _resolver; @@ -284,7 +440,11 @@ class Service extends ListArrayTreeNode private final java.util.List _adapters = new java.util.LinkedList(); private final java.util.List _dbEnvs = new java.util.LinkedList(); + private boolean _started = false; + static private ServiceEditor _editor; static private DefaultTreeCellRenderer _cellRenderer; static private JPopupMenu _popup; + static private Icon _startedIcon; + static private Icon _stoppedIcon; } diff --git a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java index e4768aa7c19..5286212a131 100755 --- a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java @@ -8,17 +8,36 @@ // ********************************************************************** package IceGridGUI.LiveDeployment; +import javax.swing.JCheckBox; import javax.swing.JTextField; import com.jgoodies.forms.builder.DefaultFormBuilder; +import javax.swing.JToolBar; + +import com.jgoodies.looks.Options; +import com.jgoodies.looks.HeaderStyle; +import com.jgoodies.looks.BorderStyle; +import com.jgoodies.looks.plastic.PlasticLookAndFeel; + import IceGrid.*; import IceGridGUI.*; class ServiceEditor extends CommunicatorEditor { - ServiceEditor() + public JToolBar getToolBar() + { + if(_toolBar == null) + { + _toolBar = new ToolBar(); + } + return _toolBar; + } + + ServiceEditor(Coordinator coordinator) { + _coordinator = coordinator; _entry.setEditable(false); + _started.setEnabled(false); } void show(Service service) @@ -28,11 +47,18 @@ class ServiceEditor extends CommunicatorEditor show(descriptor, service.getProperties(), resolver); _entry.setText(resolver.substitute(descriptor.entry)); + _started.setSelected(service.isStarted()); } - protected void appendProperties(DefaultFormBuilder builder) { + builder.appendSeparator("Runtime Status"); + + builder.append("", _started); + builder.nextLine(); + + builder.appendSeparator("Configuration"); + super.appendProperties(builder); builder.append("Entry Point"); @@ -46,6 +72,26 @@ class ServiceEditor extends CommunicatorEditor _propertiesPanel.setName("Service Properties"); } + + private class ToolBar extends JToolBar + { + private ToolBar() + { + putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE); + putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); + setFloatable(false); + putClientProperty("JToolBar.isRollover", Boolean.TRUE); + + LiveActions la = _coordinator.getLiveActionsForMenu(); + + add(la.get(TreeNode.START)); + add(la.get(TreeNode.STOP)); + } + } + + private final Coordinator _coordinator; private JTextField _entry = new JTextField(20); + private JCheckBox _started = new JCheckBox("Started"); + private JToolBar _toolBar; } diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java index f9935bded5b..b42e0f9d346 100755 --- a/java/src/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/SessionKeeper.java @@ -55,7 +55,7 @@ class SessionKeeper try { - _admin = session.getAdmin(); + _admin = _session.getAdmin(); } catch(Ice.LocalException e) { @@ -73,6 +73,47 @@ class SessionKeeper _admin = AdminPrxHelper.uncheckedCast(_admin.ice_endpoints(session.ice_getEndpoints())); } + try + { + if(_coordinator.getCommunicator().getDefaultRouter() == null) + { + Ice.ObjectPrx adminCallbackTemplate = _session.getAdminCallbackTemplate(); + + if(adminCallbackTemplate != null) + { + _adminCallbackCategory = adminCallbackTemplate.ice_getIdentity().category; + + Ice.Endpoint[] endpoints = adminCallbackTemplate.ice_getEndpoints(); + String publishedEndpoints = null; + for(int i = 0; i < endpoints.length; ++i) + { + String endpointString = endpoints[i].toString(); + if(publishedEndpoints == null) + { + publishedEndpoints = endpointString; + } + else + { + publishedEndpoints += ":" + endpointString; + } + } + _coordinator.getCommunicator().getProperties().setProperty("CallbackAdapter.PublishedEndpoints", publishedEndpoints); + } + } + _serverAdminCategory = _admin.getServerAdminCategory(); + + } + catch(Ice.LocalException e) + { + logout(true); + JOptionPane.showMessageDialog( + parent, + "Could not retrieve admin callback template or server admin category: " + e.toString(), + "Login failed", + JOptionPane.ERROR_MESSAGE); + throw e; + } + _thread = new Pinger(_session, keepAliveperiod); _thread.start(); @@ -110,6 +151,11 @@ class SessionKeeper return _admin; } + String getServerAdminCategory() + { + return _serverAdminCategory; + } + AdminPrx getRoutedAdmin() { assert _admin != null; @@ -134,6 +180,30 @@ class SessionKeeper return _routedAdmin; } + Ice.ObjectPrx addCallback(Ice.Object servant, String name, String facet) + { + if(_adminCallbackCategory == null) + { + return null; + } + else + { + return _adapter.addFacet(servant, new Ice.Identity(name, _adminCallbackCategory), facet); + } + } + + Ice.Object removeCallback(String name, String facet) + { + if(_adminCallbackCategory == null) + { + return null; + } + else + { + return _adapter.removeFacet(new Ice.Identity(name, _adminCallbackCategory), facet); + } + } + void close(boolean destroySession) { if(_thread != null) @@ -155,45 +225,8 @@ class SessionKeeper if(_adapter != null) { - try - { - _adapter.remove(_applicationObserverIdentity); - } - catch(Ice.NotRegisteredException e) - { - } - - try - { - _adapter.remove(_adapterObserverIdentity); - } - catch(Ice.NotRegisteredException e) - { - } - - try - { - _adapter.remove(_objectObserverIdentity); - } - catch(Ice.NotRegisteredException e) - { - } - - try - { - _adapter.remove(_registryObserverIdentity); - } - catch(Ice.NotRegisteredException e) - { - } - - try - { - _adapter.remove(_nodeObserverIdentity); - } - catch(Ice.NotRegisteredException e) - { - } + _adapter.destroy(); + _adapter = null; } if(destroySession) @@ -215,16 +248,19 @@ class SessionKeeper if(router == null) { category = "observer"; + + String adapterName = _adminCallbackCategory == null ? "" : "CallbackAdapter"; _adapter = - _coordinator.getCommunicator().createObjectAdapter(""); + _coordinator.getCommunicator().createObjectAdapter(adapterName); _adapter.activate(); _session.ice_getConnection().setAdapter(_adapter); } else { category = router.getCategoryForClient(); - + _adminCallbackCategory = category; + _adapter = _coordinator.getCommunicator().createObjectAdapterWithRouter("RoutedAdapter", router); _adapter.activate(); @@ -302,10 +338,13 @@ class SessionKeeper private final AdminSessionPrx _session; + private Pinger _thread; private Ice.ObjectAdapter _adapter; private AdminPrx _admin; + private String _serverAdminCategory; + private String _adminCallbackCategory; private AdminPrx _routedAdmin; private Ice.Identity _applicationObserverIdentity = new Ice.Identity(); private Ice.Identity _adapterObserverIdentity = new Ice.Identity(); @@ -1276,6 +1315,21 @@ class SessionKeeper return _session == null ? null : _session.getAdmin(); } + String getServerAdminCategory() + { + return _session == null ? null : _session.getServerAdminCategory(); + } + + Ice.ObjectPrx addCallback(Ice.Object servant, String name, String facet) + { + return _session == null ? null : _session.addCallback(servant, name, facet); + } + + Ice.Object removeCallback(String name, String facet) + { + return _session == null ? null : _session.removeCallback(name, facet); + } + AdminPrx getRoutedAdmin() { return _session == null ? null : _session.getRoutedAdmin(); diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 49e5b9e5673..f2875dea766 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -7,7 +7,7 @@ // // ********************************************************************** // -// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Nov 26 11:29:02 2007 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Nov 29 17:38:46 2007 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -126,6 +126,7 @@ public final class PropertyNames public static final Property IceBoxProps[] = { + new Property("IceBox\\.InheritProperties", false, null), new Property("IceBox\\.InstanceName", false, null), new Property("IceBox\\.LoadOrder", false, null), new Property("IceBox\\.PrintServicesReady", false, null), @@ -143,8 +144,8 @@ public final class PropertyNames new Property("IceBox\\.ServiceManager\\.ThreadPool\\.SizeMax", false, null), new Property("IceBox\\.ServiceManager\\.ThreadPool\\.SizeWarn", false, null), new Property("IceBox\\.ServiceManager\\.ThreadPool\\.StackSize", false, null), + new Property("IceBox\\.Trace\\.ServiceObserver", false, null), new Property("IceBox\\.UseSharedCommunicator\\.[^\\s]+", false, null), - new Property("IceBox\\.InheritProperties", false, null), null }; @@ -217,6 +218,19 @@ public final class PropertyNames new Property("IceGrid\\.Node\\.UserAccountMapper\\.ThreadPerConnection", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper", false, null), new Property("IceGrid\\.Node\\.WaitTime", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.AdapterId", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.Endpoints", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.Locator", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.PublishedEndpoints", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.RegisterProcess", true, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ReplicaGroupId", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.Router", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPerConnection", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPerConnection\\.StackSize", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPool\\.Size", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPool\\.SizeMax", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPool\\.SizeWarn", false, null), + new Property("IceGrid\\.Registry\\.AdminCallbackRouter\\.ThreadPool\\.StackSize", false, null), new Property("IceGrid\\.Registry\\.AdminCryptPasswords", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.EndpointSelection", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.ConnectionCached", false, null), @@ -229,6 +243,19 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.ThreadPerConnection", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier", false, null), new Property("IceGrid\\.Registry\\.AdminSessionFilters", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.AdapterId", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Endpoints", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.PublishedEndpoints", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.RegisterProcess", true, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ReplicaGroupId", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPerConnection", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPerConnection\\.StackSize", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.Size", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.SizeMax", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.SizeWarn", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.StackSize", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.EndpointSelection", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.PreferSecure", false, null), @@ -309,19 +336,6 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.SessionManager\\.ThreadPool\\.SizeMax", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.ThreadPool\\.SizeWarn", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.ThreadPool\\.StackSize", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.AdapterId", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Endpoints", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.PublishedEndpoints", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.RegisterProcess", true, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ReplicaGroupId", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPerConnection", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPerConnection\\.StackSize", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.Size", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.SizeMax", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.SizeWarn", false, null), - new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ThreadPool\\.StackSize", false, null), new Property("IceGrid\\.Registry\\.SessionTimeout", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.EndpointSelection", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.ConnectionCached", false, null), |