diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceBox/ServiceManagerI.java | 77 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Server.java | 14 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/ServerEditor.java | 46 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Service.java | 63 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/ServiceEditor.java | 109 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java | 208 |
6 files changed, 361 insertions, 156 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index 134425e06b6..471e5aebaac 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -291,7 +291,35 @@ public class ServiceManagerI extends _ServiceManagerDisp // _server.shutdownOnInterrupt(); + + // + // Register "this" as a facet to the Admin object and + // create Admin object // + try + { + _server.communicator().addAdminFacet(this, "IceBox.ServiceManager"); + + // + // Add a Properties facet for each service + // + for(ServiceInfo info: _services) + { + Ice.Communicator communicator = info.communicator != null ? info.communicator : _server.communicator(); + _server.communicator().addAdminFacet(new PropertiesAdminI(communicator.getProperties()), + "IceBox.Service." + info.name + ".Properties"); + } + + _server.communicator().getAdmin(); + } + catch(Ice.ObjectAdapterDeactivatedException ex) + { + // + // Expected if the communicator has been shutdown. + // + } + + // // Start request dispatching after we've started the services. // if(adapter != null) @@ -308,22 +336,6 @@ public class ServiceManagerI extends _ServiceManagerDisp } } - // - // Register "this" as a facet to the Admin object and - // create Admin object - // - try - { - _server.communicator().addAdminFacet(this, "IceBox.ServiceManager"); - _server.communicator().getAdmin(); - } - catch(Ice.ObjectAdapterDeactivatedException ex) - { - // - // Expected if the communicator has been shutdown. - // - } - _server.communicator().waitForShutdown(); _server.defaultInterrupt(); @@ -669,6 +681,15 @@ public class ServiceManagerI extends _ServiceManagerDisp { try { + _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties"); + } + catch(Ice.LocalException e) + { + // Ignored + } + + try + { info.communicator.shutdown(); info.communicator.waitForShutdown(); } @@ -817,7 +838,7 @@ public class ServiceManagerI extends _ServiceManagerDisp } } - class ServiceInfo + static class ServiceInfo { public String name; public Service service; @@ -826,6 +847,28 @@ public class ServiceManagerI extends _ServiceManagerDisp public String[] args; } + static class PropertiesAdminI extends Ice._PropertiesAdminDisp + { + PropertiesAdminI(Ice.Properties properties) + { + _properties = properties; + } + + public String + getProperty(String name, Ice.Current current) + { + return _properties.getProperty(name); + } + + public java.util.TreeMap + getPropertiesForPrefix(String name, Ice.Current current) + { + return new java.util.TreeMap(_properties.getPropertiesForPrefix(name)); + } + + private final Ice.Properties _properties; + } + private Ice.Application _server; private Ice.Logger _logger; private String[] _argv; // Filtered server argument vector diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index ecd00d6bf01..13ede590e09 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -296,19 +296,12 @@ class Server extends ListArrayTreeNode try { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); getCoordinator().getAdmin().sendSignal_async(cb, _id, s); } catch(Ice.LocalException e) { failure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); } - finally - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } } public void patchServer() @@ -421,7 +414,7 @@ class Server extends ListArrayTreeNode } } - public void showRuntimeProperties() + void showRuntimeProperties() { Ice.ObjectPrx serverAdmin = getServerAdmin(); @@ -995,6 +988,11 @@ class Server extends ListArrayTreeNode return Utils.propertySetsToMap(psList, _resolver); } + int getIceVersion() + { + return Utils.getIntVersion(Utils.substitute(_serverDescriptor.iceVersion, _resolver)); + } + private void createAdapters() { java.util.Iterator p = _serverDescriptor.adapters.iterator(); diff --git a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java index d46894fbde1..4924c1bac4d 100755 --- a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java @@ -119,40 +119,36 @@ class ServerEditor extends CommunicatorEditor { _currentState.setText(state.toString()); _enabled.setSelected(server.isEnabled()); + int pid = server.getPid(); if(pid == 0) { _currentPid.setText(""); - _buildId.setText(""); - _properties.clear(); - _refreshButton.setEnabled(false); } else { _currentPid.setText(Integer.toString(pid)); - - int iceIntVersion = Utils.getIntVersion(resolver.substitute(descriptor.iceVersion)); + } - if(iceIntVersion == 0 || iceIntVersion >= 30300) - { - _buildId.setText("Retrieving..."); - _properties.clear(); - - // - // Retrieve all properties in background - // - _target.showRuntimeProperties(); - _refreshButton.setEnabled(true); - } - else - { - _buildId.setText(""); - _properties.clear(); - _refreshButton.setEnabled(false); - } + int iceIntVersion = server.getIceVersion(); + if(state == ServerState.Active && (iceIntVersion == 0 || iceIntVersion >= 30300)) + { + _buildId.setText("Retrieving..."); + _properties.clear(); + + // + // Retrieve all properties in background + // + _target.showRuntimeProperties(); + _refreshButton.setEnabled(true); + } + else + { + _buildId.setText(""); + _properties.clear(); + _refreshButton.setEnabled(false); } } - _application.setText(resolver.find("application")); @@ -210,7 +206,7 @@ class ServerEditor extends CommunicatorEditor // That's to report error messages // - if(server == _target && _target.getPid() != 0) + if(server == _target) { _buildId.setText(buildString); } @@ -221,7 +217,7 @@ class ServerEditor extends CommunicatorEditor void setRuntimeProperties(java.util.SortedMap map, Server server) { - if(server == _target && _target.getPid() != 0) + if(server == _target) { _properties.setSortedMap(map); diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java index b6ee324a0ec..5dcf2e3bfe3 100755 --- a/java/src/IceGridGUI/LiveDeployment/Service.java +++ b/java/src/IceGridGUI/LiveDeployment/Service.java @@ -13,6 +13,7 @@ import javax.swing.Icon; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTree; +import javax.swing.SwingUtilities; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; @@ -357,6 +358,68 @@ class Service extends ListArrayTreeNode } } + + void showRuntimeProperties() + { + Ice.ObjectPrx serverAdmin = ((Server)_parent).getServerAdmin(); + + if(serverAdmin == null) + { + _editor.setBuildId("", this); + } + else + { + 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, Service.this); + } + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(e instanceof Ice.ObjectNotExistException) + { + _editor.setBuildId("Error: can't reach the icebox Admin object", Service.this); + } + else if(e instanceof Ice.FacetNotExistException) + { + _editor.setBuildId("Error: this icebox Admin object does not provide a 'Properties' facet for this service", + Service.this); + } + else + { + _editor.setBuildId("Error: " + e.toString(), Service.this); + } + } + }); + } + }; + + + try + { + Ice.PropertiesAdminPrx propAdmin = Ice.PropertiesAdminPrxHelper.uncheckedCast(serverAdmin.ice_facet("IceBox.Service." + + _id + ".Properties")); + propAdmin.getPropertiesForPrefix_async(cb, ""); + } + catch(Ice.LocalException e) + { + _editor.setBuildId("Error: " + e.toString(), this); + } + } + } + Utils.Resolver getResolver() { return _resolver; diff --git a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java index 5286212a131..52c957db23d 100755 --- a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java @@ -8,11 +8,19 @@ // ********************************************************************** package IceGridGUI.LiveDeployment; +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; import javax.swing.JCheckBox; +import javax.swing.JScrollPane; import javax.swing.JTextField; -import com.jgoodies.forms.builder.DefaultFormBuilder; import javax.swing.JToolBar; +import com.jgoodies.forms.builder.DefaultFormBuilder; +import com.jgoodies.forms.layout.CellConstraints; + import com.jgoodies.looks.Options; import com.jgoodies.looks.HeaderStyle; import com.jgoodies.looks.BorderStyle; @@ -38,16 +46,55 @@ class ServiceEditor extends CommunicatorEditor _coordinator = coordinator; _entry.setEditable(false); _started.setEnabled(false); + + _buildId.setEditable(false); + + Action refresh = new AbstractAction("Refresh") + { + public void actionPerformed(ActionEvent e) + { + _buildId.setText("Retrieving..."); + _properties.clear(); + _target.showRuntimeProperties(); + } + }; + refresh.putValue(Action.SHORT_DESCRIPTION, + "Reread the properties from the service"); + _refreshButton = new JButton(refresh); } void show(Service service) { + _target = service; + ServiceDescriptor descriptor = service.getServiceDescriptor(); Utils.Resolver resolver = service.getResolver(); show(descriptor, service.getProperties(), resolver); _entry.setText(resolver.substitute(descriptor.entry)); _started.setSelected(service.isStarted()); + + Server server = (Server)service.getParent(); + + int iceIntVersion = server.getIceVersion(); + + if(server.getState() == ServerState.Active && (iceIntVersion == 0 || iceIntVersion >= 30300)) + { + _buildId.setText("Retrieving..."); + _properties.clear(); + + // + // Retrieve all properties in background + // + _target.showRuntimeProperties(); + _refreshButton.setEnabled(true); + } + else + { + _buildId.setText(""); + _properties.clear(); + _refreshButton.setEnabled(false); + } } protected void appendProperties(DefaultFormBuilder builder) @@ -56,6 +103,27 @@ class ServiceEditor extends CommunicatorEditor builder.append("", _started); builder.nextLine(); + + builder.append("Build Id"); + builder.append(_buildId, _refreshButton); + builder.nextLine(); + + builder.append("Properties"); + builder.nextLine(); + builder.append(""); + builder.nextLine(); + builder.append(""); + + builder.nextLine(); + builder.append(""); + + builder.nextRow(-6); + CellConstraints cc = new CellConstraints(); + JScrollPane scrollPane = new JScrollPane(_properties); + builder.add(scrollPane, + cc.xywh(builder.getColumn(), builder.getRow(), 3, 7)); + builder.nextRow(6); + builder.nextLine(); builder.appendSeparator("Configuration"); @@ -72,6 +140,41 @@ class ServiceEditor extends CommunicatorEditor _propertiesPanel.setName("Service Properties"); } + void setBuildId(String buildString, Service service) + { + // + // That's to report error messages + // + + if(service == _target) + { + _buildId.setText(buildString); + } + // + // Otherwise we've already moved to another server + // + } + + void setRuntimeProperties(java.util.SortedMap map, Service service) + { + if(service == _target ) + { + _properties.setSortedMap(map); + + String buildString = (String)map.get("BuildId"); + if(buildString == null) + { + _buildId.setText(""); + } + else + { + _buildId.setText(buildString); + } + } + // + // Otherwise we've already moved to another server + // + } private class ToolBar extends JToolBar { @@ -90,8 +193,12 @@ class ServiceEditor extends CommunicatorEditor } private final Coordinator _coordinator; + private Service _target; private JTextField _entry = new JTextField(20); private JCheckBox _started = new JCheckBox("Started"); + private JTextField _buildId = new JTextField(20); + private JButton _refreshButton; + private TableField _properties = new TableField("Name", "Value"); private JToolBar _toolBar; } diff --git a/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java index 7c6f1cba72c..1575a3c27da 100644 --- a/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java @@ -64,124 +64,122 @@ class WriteMessageDialog extends JDialog public void actionPerformed(ActionEvent e) { final Coordinator c = root.getCoordinator(); - final String target = _target; - final String prefix = "Writing message to server '" + target + "'..."; - + + AdminPrx admin = c.getAdmin(); + if(admin == null) + { + JOptionPane.showMessageDialog( + _mainFrame, + "No longer connected to IceGrid Registry", + "Writing message to server '" + _target + "' failed", + JOptionPane.ERROR_MESSAGE); + } + else + { + + Ice.Identity adminId = new Ice.Identity(_target, c.getServerAdminCategory()); + + final Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast( + admin.ice_identity(adminId).ice_facet("Process")); + + final String prefix = "Writing message to server '" + _target + "'..."; + c.getStatusBar().setText(prefix); - AMI_Admin_writeMessage cb = new AMI_Admin_writeMessage() - { - public void ice_response() + Ice.AMI_Process_writeMessage cb = new Ice.AMI_Process_writeMessage() { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - c.getStatusBar().setText(prefix + "done."); - } - }); - } - - public void ice_exception(final Ice.UserException e) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleFailure("IceGrid exception: " + e.toString()); - } - - }); - } + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + c.getStatusBar().setText(prefix + "done."); + } + }); + } - public void ice_exception(final Ice.LocalException e) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() { - handleFailure("Communication exception: " + e.toString()); - } - }); - } - - private void handleFailure(String message) - { - c.getStatusBar().setText(prefix + "failed!"); + public void run() + { + handleFailure("Communication exception: " + e.toString()); + } + }); + } + + private void handleFailure(String message) + { + c.getStatusBar().setText(prefix + "failed!"); - JOptionPane.showMessageDialog( - _mainFrame, - message, - "Writing message to server '" + target + "' failed", - JOptionPane.ERROR_MESSAGE); - } - }; + JOptionPane.showMessageDialog( + _mainFrame, + message, + "Writing message to server '" + process.ice_getIdentity().name + "' failed", + JOptionPane.ERROR_MESSAGE); + } + }; - try - { - c.getStatusBar().setText(prefix); - _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - c.getAdmin().writeMessage_async( - cb, _target, _message.getText(), _stdOut.isSelected() ? 1 : 2); - } - catch(Ice.LocalException ex) - { - c.getStatusBar().setText(prefix + "failed."); - JOptionPane.showMessageDialog( - _mainFrame, - "Communication exception: " + ex.toString(), - "Writing message to server '" + target + "' failed", - JOptionPane.ERROR_MESSAGE); + try + { + process.writeMessage_async(cb, _message.getText(), _stdOut.isSelected() ? 1 : 2); + } + catch(Ice.LocalException ex) + { + c.getStatusBar().setText(prefix + "failed."); + JOptionPane.showMessageDialog( + _mainFrame, + "Communication exception: " + ex.toString(), + "Writing message to server '" + _target + "' failed", + JOptionPane.ERROR_MESSAGE); - return; - } - finally - { - _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + return; + } } - + setVisible(false); } }; - okButton.addActionListener(okListener); - getRootPane().setDefaultButton(okButton); + okButton.addActionListener(okListener); + getRootPane().setDefaultButton(okButton); - JButton cancelButton = new JButton("Cancel"); - ActionListener cancelListener = new ActionListener() + JButton cancelButton = new JButton("Cancel"); + ActionListener cancelListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - setVisible(false); - } - }; - cancelButton.addActionListener(cancelListener); - - FormLayout layout = new FormLayout("left:pref, 3dlu, fill:pref:grow", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.setRowGroupingEnabled(true); - builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); - - _message.setLineWrap(true); - JScrollPane scrollPane = new JScrollPane(_message, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - builder.append(scrollPane, 3); - builder.nextLine(); - builder.append(_stdOut); - builder.append(stdErr); - builder.nextLine(); - JComponent buttonBar = - ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); - buttonBar.setBorder(Borders.DIALOG_BORDER); - - Container contentPane = getContentPane(); - contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); - contentPane.add(builder.getPanel()); - contentPane.add(buttonBar); - - pack(); - setResizable(false); + setVisible(false); + } + }; + cancelButton.addActionListener(cancelListener); + + FormLayout layout = new FormLayout("left:pref, 3dlu, fill:pref:grow", ""); + DefaultFormBuilder builder = new DefaultFormBuilder(layout); + builder.setDefaultDialogBorder(); + builder.setRowGroupingEnabled(true); + builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); + + _message.setLineWrap(true); + JScrollPane scrollPane = new JScrollPane(_message, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + builder.append(scrollPane, 3); + builder.nextLine(); + builder.append(_stdOut); + builder.append(stdErr); + builder.nextLine(); + JComponent buttonBar = + ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); + buttonBar.setBorder(Borders.DIALOG_BORDER); + + Container contentPane = getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(builder.getPanel()); + contentPane.add(buttonBar); + + pack(); + setResizable(false); } void showDialog(String serverId) |