diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-12-18 19:31:28 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-12-18 19:31:28 +0000 |
commit | aedd8466aedc76ee0af8bc730feb973ee6f44c6a (patch) | |
tree | 85911efa70a0dce16947abfc470e6379a0e8c6d3 | |
parent | Fixed Windows compile error (diff) | |
download | ice-aedd8466aedc76ee0af8bc730feb973ee6f44c6a.tar.bz2 ice-aedd8466aedc76ee0af8bc730feb973ee6f44c6a.tar.xz ice-aedd8466aedc76ee0af8bc730feb973ee6f44c6a.zip |
Added support for user-defined log files
-rwxr-xr-x | java/src/IceGridGUI/Application/CommunicatorSubEditor.java | 92 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/DbEnvEditor.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/MapField.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PlainServer.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertiesField.java | 11 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertySetEditor.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServerInstanceEditor.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServiceInstanceEditor.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Coordinator.java | 32 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveActions.java | 12 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Server.java | 77 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Service.java | 86 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/TreeNode.java | 15 |
13 files changed, 308 insertions, 29 deletions
diff --git a/java/src/IceGridGUI/Application/CommunicatorSubEditor.java b/java/src/IceGridGUI/Application/CommunicatorSubEditor.java index 22e68e62bfb..ab3506a59a0 100755 --- a/java/src/IceGridGUI/Application/CommunicatorSubEditor.java +++ b/java/src/IceGridGUI/Application/CommunicatorSubEditor.java @@ -37,6 +37,10 @@ class CommunicatorSubEditor _mainEditor.getUpdateListener()); _properties = new PropertiesField(mainEditor); _description.setToolTipText("Property Set References"); + + _logFiles = new MapField(mainEditor, "Path", "Property name", + true); + _logFiles.setToolTipText("Log files used by this server or service"); } @@ -62,7 +66,6 @@ class CommunicatorSubEditor builder.append(""); builder.nextLine(); builder.append(""); - builder.nextLine(); builder.append(""); @@ -72,6 +75,18 @@ class CommunicatorSubEditor cc.xywh(builder.getColumn(), builder.getRow(), 3, 7)); builder.nextRow(6); builder.nextLine(); + + builder.append("Log files"); + builder.nextLine(); + builder.append(""); + builder.nextLine(); + builder.append(""); + builder.nextRow(-4); + scrollPane = new JScrollPane(_logFiles); + builder.add(scrollPane, + cc.xywh(builder.getColumn(), builder.getRow(), 3, 5)); + builder.nextRow(4); + builder.nextLine(); } void writeDescriptor(CommunicatorDescriptor descriptor) @@ -80,6 +95,24 @@ class CommunicatorSubEditor (String[])_propertySets.getList().toArray(new String[0]); descriptor.propertySet.properties = _properties.getProperties(); descriptor.description = _description.getText(); + + java.util.TreeMap tm = _logFiles.get(); + java.util.Iterator p = tm.entrySet().iterator(); + descriptor.logs = new LogDescriptor[tm.size()]; + int i = 0; + + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + String path = (String)entry.getKey(); + String prop = ((String)entry.getValue()).trim(); + + descriptor.logs[i++] = new LogDescriptor(path, ""); + if(!prop.equals("")) + { + setProperty((java.util.LinkedList)descriptor.propertySet.properties, prop, path); + } + } } void show(CommunicatorDescriptor descriptor, boolean isEditable) @@ -87,12 +120,28 @@ class CommunicatorSubEditor Utils.Resolver detailResolver = _mainEditor.getDetailResolver(); isEditable = isEditable && (detailResolver == null); + java.util.Map map = new java.util.TreeMap(); + java.util.List logProps = new java.util.LinkedList(); + for(int i = 0; i < descriptor.logs.length; ++i) + { + String prop = lookupKey(descriptor.propertySet.properties, + descriptor.logs[i].path); + + map.put(descriptor.logs[i].path, prop); + if(!prop.equals("")) + { + logProps.add(prop); + } + } + + _logFiles.set(map, detailResolver, isEditable); + _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references), detailResolver); _propertySets.setEditable(isEditable); - _properties.setProperties(descriptor.propertySet.properties, descriptor.adapters, + logProps, detailResolver, isEditable); _description.setText( @@ -101,9 +150,48 @@ class CommunicatorSubEditor _description.setOpaque(isEditable); } + + // + // Returns first key matching this value, if there is one + // + private String lookupKey(java.util.List props, String value) + { + java.util.Iterator p = props.iterator(); + while(p.hasNext()) + { + PropertyDescriptor pd = (PropertyDescriptor)p.next(); + if(pd.value.equals(value)) + { + return pd.name; + } + } + return ""; + } + + private void setProperty(java.util.LinkedList props, String key, String newValue) + { + removeProperty(props, key); + props.addFirst(new PropertyDescriptor(key, newValue)); + } + + private void removeProperty(java.util.List props, String key) + { + java.util.Iterator p = props.iterator(); + while(p.hasNext()) + { + PropertyDescriptor pd = (PropertyDescriptor)p.next(); + if(pd.name.equals(key)) + { + p.remove(); + } + } + } + + protected Editor _mainEditor; private JTextArea _description = new JTextArea(3, 20); private ListTextField _propertySets = new ListTextField(20); private PropertiesField _properties; + private MapField _logFiles; } diff --git a/java/src/IceGridGUI/Application/DbEnvEditor.java b/java/src/IceGridGUI/Application/DbEnvEditor.java index e7f83f50c4a..34bdbc734ae 100755 --- a/java/src/IceGridGUI/Application/DbEnvEditor.java +++ b/java/src/IceGridGUI/Application/DbEnvEditor.java @@ -146,7 +146,7 @@ class DbEnvEditor extends CommunicatorChildEditor _dbHome.setEnabled(isEditable); _dbHome.setEditable(isEditable); - _properties.setProperties(descriptor.properties, null, + _properties.setProperties(descriptor.properties, null, null, resolver, isEditable); _applyButton.setEnabled(dbEnv.isEphemeral()); diff --git a/java/src/IceGridGUI/Application/MapField.java b/java/src/IceGridGUI/Application/MapField.java index e0df77800a4..7049cdf61c7 100755 --- a/java/src/IceGridGUI/Application/MapField.java +++ b/java/src/IceGridGUI/Application/MapField.java @@ -170,7 +170,7 @@ public class MapField extends JTable key = key.trim(); if(!key.equals("")) { - String val = (String) row.elementAt(1); + String val = (String)row.elementAt(1); if(val == null) { val = ""; diff --git a/java/src/IceGridGUI/Application/PlainServer.java b/java/src/IceGridGUI/Application/PlainServer.java index fd854398a79..e5a24e52092 100755 --- a/java/src/IceGridGUI/Application/PlainServer.java +++ b/java/src/IceGridGUI/Application/PlainServer.java @@ -90,7 +90,7 @@ class PlainServer extends Communicator implements Server java.util.LinkedList properties = new java.util.LinkedList(); properties.add(new PropertyDescriptor("IceBox.InstanceName", "${server}")); properties.add(new PropertyDescriptor("Ice.OA.IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1")); - properties.add(new PropertyDescriptor("Ice.OA.IceBox.RegisterProcess", "1")); + properties.add(new PropertyDescriptor("Ice.OA.IceBox.ServiceManager.RegisterProcess", "1")); return new IceBoxDescriptor( new java.util.LinkedList(), diff --git a/java/src/IceGridGUI/Application/PropertiesField.java b/java/src/IceGridGUI/Application/PropertiesField.java index f5e84bf10ff..5463683195e 100755 --- a/java/src/IceGridGUI/Application/PropertiesField.java +++ b/java/src/IceGridGUI/Application/PropertiesField.java @@ -77,6 +77,7 @@ public class PropertiesField extends JTable public void setProperties(java.util.List properties, java.util.List adapters, + java.util.List logProps, Utils.Resolver resolver, boolean editable) { _editable = editable; @@ -99,6 +100,15 @@ public class PropertiesField extends JTable } } + if(logProps != null) + { + java.util.Iterator p = logProps.iterator(); + while(p.hasNext()) + { + hiddenPropertyNames.add(p.next()); + } + } + // // Transform list into vector of vectors // @@ -174,7 +184,6 @@ public class PropertiesField extends JTable cr.setOpaque(_editable); } - public java.util.LinkedList getProperties() { assert _editable; diff --git a/java/src/IceGridGUI/Application/PropertySetEditor.java b/java/src/IceGridGUI/Application/PropertySetEditor.java index df75b04b7dc..2164a65631f 100755 --- a/java/src/IceGridGUI/Application/PropertySetEditor.java +++ b/java/src/IceGridGUI/Application/PropertySetEditor.java @@ -237,7 +237,7 @@ class PropertySetEditor extends Editor resolver); _propertySets.setEditable(isEditable); - _properties.setProperties(descriptor.properties, null, + _properties.setProperties(descriptor.properties, null, null, getDetailResolver(), isEditable); _applyButton.setEnabled(nps.isEphemeral()); diff --git a/java/src/IceGridGUI/Application/ServerInstanceEditor.java b/java/src/IceGridGUI/Application/ServerInstanceEditor.java index 99a802969d7..cd202ecd1ed 100755 --- a/java/src/IceGridGUI/Application/ServerInstanceEditor.java +++ b/java/src/IceGridGUI/Application/ServerInstanceEditor.java @@ -211,7 +211,7 @@ class ServerInstanceEditor extends AbstractServerEditor getDetailResolver()); _propertySets.setEditable(isEditable); - _properties.setProperties(descriptor.propertySet.properties, null, + _properties.setProperties(descriptor.propertySet.properties, null, null, getDetailResolver(), isEditable); _applyButton.setEnabled(server.isEphemeral()); diff --git a/java/src/IceGridGUI/Application/ServiceInstanceEditor.java b/java/src/IceGridGUI/Application/ServiceInstanceEditor.java index b59efc5d853..fd0c29efeb0 100755 --- a/java/src/IceGridGUI/Application/ServiceInstanceEditor.java +++ b/java/src/IceGridGUI/Application/ServiceInstanceEditor.java @@ -222,7 +222,7 @@ class ServiceInstanceEditor extends CommunicatorChildEditor getDetailResolver()); _propertySets.setEditable(isEditable); - _properties.setProperties(descriptor.propertySet.properties, null, + _properties.setProperties(descriptor.propertySet.properties, null, null, getDetailResolver(), isEditable); _applyButton.setEnabled(service.isEphemeral()); diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index c6909a76fe8..bc48d8389d7 100755 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -449,6 +449,12 @@ public class Coordinator _serverMenu.addSeparator(); _serverMenu.add(_liveActionsForMenu.get( IceGridGUI.LiveDeployment.TreeNode.WRITE_MESSAGE)); + _serverMenu.add(_liveActionsForMenu.get( + IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_STDOUT)); + _serverMenu.add(_liveActionsForMenu.get( + IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_STDERR)); + _serverMenu.add(_liveActionsForMenu.get( + IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_LOG)); _serverMenu.addSeparator(); _signalMenu = new JMenu("Send Signal"); _serverMenu.add(_signalMenu); @@ -461,6 +467,15 @@ public class Coordinator _signalMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.SIGTERM)); // + // Service sub-menu + // + _serviceMenu = new JMenu("Service"); + _serviceMenu.setEnabled(false); + toolsMenu.add(_serviceMenu); + _serviceMenu.add(_liveActionsForMenu.get( + IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_LOG)); + + // // Help menu // JMenu helpMenu = new JMenu("Help"); @@ -2344,15 +2359,23 @@ public class Coordinator availableActions[IceGridGUI.LiveDeployment.TreeNode.ADD_OBJECT] || availableActions[IceGridGUI.LiveDeployment.TreeNode.SHUTDOWN_REGISTRY]); + _signalMenu.setEnabled( + availableActions[IceGridGUI.LiveDeployment.TreeNode.SIGHUP]); + _serverMenu.setEnabled( availableActions[IceGridGUI.LiveDeployment.TreeNode.START] || availableActions[IceGridGUI.LiveDeployment.TreeNode.STOP] || availableActions[IceGridGUI.LiveDeployment.TreeNode.ENABLE] || availableActions[IceGridGUI.LiveDeployment.TreeNode.DISABLE] || - availableActions[IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER]); - - _signalMenu.setEnabled( + availableActions[IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER] || + availableActions[IceGridGUI.LiveDeployment.TreeNode.WRITE_MESSAGE] || + availableActions[IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_STDOUT] || + availableActions[IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_STDERR] || + availableActions[IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_LOG] || availableActions[IceGridGUI.LiveDeployment.TreeNode.SIGHUP]); + + _serviceMenu.setEnabled( + availableActions[IceGridGUI.LiveDeployment.TreeNode.RETRIEVE_LOG]); } public void showActions(IceGridGUI.Application.TreeNode node) @@ -2377,7 +2400,9 @@ public class Coordinator _appMenu.setEnabled(false); _nodeMenu.setEnabled(false); _registryMenu.setEnabled(false); + _signalMenu.setEnabled(false); _serverMenu.setEnabled(false); + _serviceMenu.setEnabled(false); } @@ -2476,6 +2501,7 @@ public class Coordinator private JMenu _nodeMenu; private JMenu _registryMenu; private JMenu _serverMenu; + private JMenu _serviceMenu; private JMenu _signalMenu; private final Thread _shutdownHook; diff --git a/java/src/IceGridGUI/LiveActions.java b/java/src/IceGridGUI/LiveActions.java index df5d8e18af5..f49bb439b9a 100755 --- a/java/src/IceGridGUI/LiveActions.java +++ b/java/src/IceGridGUI/LiveActions.java @@ -149,7 +149,17 @@ public class LiveActions } }; _array[TreeNode.RETRIEVE_STDERR].putValue(Action.SHORT_DESCRIPTION, - "Retrieve stderr"); + "Retrieve stderr"); + + _array[TreeNode.RETRIEVE_LOG] = new AbstractAction("Retrieve Log") + { + public void actionPerformed(ActionEvent e) + { + _target.retrieveLog(); + } + }; + _array[TreeNode.RETRIEVE_LOG].putValue(Action.SHORT_DESCRIPTION, + "Retrieve log file from the server"); _array[TreeNode.SHUTDOWN_NODE] = new AbstractAction("Shutdown") diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index 6c8f524f7ba..04dcdaab559 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -44,7 +44,8 @@ class Server extends ListArrayTreeNode actions[WRITE_MESSAGE] = _state != ServerState.Inactive; actions[RETRIEVE_STDOUT] = true; actions[RETRIEVE_STDERR] = true; - + actions[RETRIEVE_LOG] = _serverDescriptor.logs.length > 0; + actions[PATCH_SERVER] = !_serverDescriptor.distrib.icepatch.equals(""); @@ -199,7 +200,60 @@ class Server extends ListArrayTreeNode } }); } + + public void retrieveLog() + { + assert _serverDescriptor.logs.length > 0; + + String path = null; + if(_serverDescriptor.logs.length == 1) + { + path = _resolver.substitute(_serverDescriptor.logs[0].path); + } + else + { + Object[] pathArray = new Object[_serverDescriptor.logs.length]; + for(int i = 0; i < _serverDescriptor.logs.length; ++i) + { + pathArray[i] = _resolver.substitute(_serverDescriptor.logs[i].path); + } + + path = (String)JOptionPane.showInputDialog( + getCoordinator().getMainFrame(), + "Which log file do you want to retrieve?", + "Retrieve Log File", + JOptionPane.QUESTION_MESSAGE, null, + pathArray, pathArray[0]); + } + + if(path != null) + { + final String fPath = path; + + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, + DeploymentException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + return adminSession.openServerLog(_id, fPath, count); + } + + public String getTitle() + { + return "Server " + _id + " " + new java.io.File(fPath).getName(); + } + + public String getDefaultFilename() + { + return new java.io.File(fPath).getName(); + } + }); + } + } + public void signal(final String s) { final String prefix = "Sending '" + s + "' to server '" + _id + "'..."; @@ -367,21 +421,23 @@ class Server extends ListArrayTreeNode _popup.add(la.get(WRITE_MESSAGE)); _popup.add(la.get(RETRIEVE_STDOUT)); _popup.add(la.get(RETRIEVE_STDERR)); + _popup.add(la.get(RETRIEVE_LOG)); _popup.addSeparator(); - JMenu signalMenu = new JMenu("Send Signal"); - _popup.add(signalMenu); + _signalMenu = new JMenu("Send Signal"); + _popup.add(_signalMenu); - signalMenu.add(la.get(SIGHUP)); - signalMenu.add(la.get(SIGINT)); - signalMenu.add(la.get(SIGQUIT)); - signalMenu.add(la.get(SIGKILL)); - signalMenu.add(la.get(SIGUSR1)); - signalMenu.add(la.get(SIGUSR2)); - signalMenu.add(la.get(SIGTERM)); + _signalMenu.add(la.get(SIGHUP)); + _signalMenu.add(la.get(SIGINT)); + _signalMenu.add(la.get(SIGQUIT)); + _signalMenu.add(la.get(SIGKILL)); + _signalMenu.add(la.get(SIGUSR1)); + _signalMenu.add(la.get(SIGUSR2)); + _signalMenu.add(la.get(SIGTERM)); } la.setTarget(this); + _signalMenu.setEnabled(la.get(SIGHUP).isEnabled()); return _popup; } @@ -872,5 +928,6 @@ class Server extends ListArrayTreeNode static private ServerEditor _editor; static private JPopupMenu _popup; + static private JMenu _signalMenu; static private WriteMessageDialog _writeMessageDialog; } diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java index 08044814473..1a1e17f0a18 100755 --- a/java/src/IceGridGUI/LiveDeployment/Service.java +++ b/java/src/IceGridGUI/LiveDeployment/Service.java @@ -9,6 +9,8 @@ package IceGridGUI.LiveDeployment; import java.awt.Component; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeModel; @@ -20,6 +22,73 @@ import IceGridGUI.*; class Service extends ListArrayTreeNode { + // + // Actions + // + public boolean[] getAvailableActions() + { + boolean[] actions = new boolean[ACTION_COUNT]; + + if(((Server)_parent).getState() != null) + { + actions[RETRIEVE_LOG] = _serviceDescriptor.logs.length > 0; + } + return actions; + } + + public void retrieveLog() + { + assert _serviceDescriptor.logs.length > 0; + + String path = null; + + if(_serviceDescriptor.logs.length == 1) + { + path = _resolver.substitute(_serviceDescriptor.logs[0].path); + } + else + { + Object[] pathArray = new Object[_serviceDescriptor.logs.length]; + for(int i = 0; i < _serviceDescriptor.logs.length; ++i) + { + pathArray[i] = _resolver.substitute(_serviceDescriptor.logs[i].path); + } + + path = (String)JOptionPane.showInputDialog( + getCoordinator().getMainFrame(), + "Which log file do you want to retrieve?", + "Retrieve Log File", + JOptionPane.QUESTION_MESSAGE, null, + pathArray, pathArray[0]); + } + + if(path != null) + { + final String fPath = path; + + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, + DeploymentException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + return adminSession.openServerLog(_parent.getId(), fPath, count); + } + + public String getTitle() + { + return "Service " + _parent.getId() + "/" + _id + " " + new java.io.File(fPath).getName(); + } + + public String getDefaultFilename() + { + return new java.io.File(fPath).getName(); + } + }); + } + } + public Component getTreeCellRendererComponent( JTree tree, Object value, @@ -53,6 +122,20 @@ class Service extends ListArrayTreeNode return _editor; } + public JPopupMenu getPopupMenu() + { + LiveActions la = getCoordinator().getLiveActionsForPopup(); + + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(la.get(RETRIEVE_LOG)); + } + + la.setTarget(this); + return _popup; + } + Service(Server parent, String serviceName, Utils.Resolver resolver, ServiceInstanceDescriptor descriptor, @@ -196,5 +279,6 @@ class Service extends ListArrayTreeNode private final java.util.List _dbEnvs = new java.util.LinkedList(); static private ServiceEditor _editor; - static private DefaultTreeCellRenderer _cellRenderer; + static private DefaultTreeCellRenderer _cellRenderer; + static private JPopupMenu _popup; } diff --git a/java/src/IceGridGUI/LiveDeployment/TreeNode.java b/java/src/IceGridGUI/LiveDeployment/TreeNode.java index 50abcf00ddd..d07f23e4e26 100755 --- a/java/src/IceGridGUI/LiveDeployment/TreeNode.java +++ b/java/src/IceGridGUI/LiveDeployment/TreeNode.java @@ -49,15 +49,16 @@ public abstract class TreeNode extends TreeNodeBase public static final int RETRIEVE_STDOUT = 12; public static final int RETRIEVE_STDERR = 13; + public static final int RETRIEVE_LOG = 14; - public static final int SHUTDOWN_NODE = 14; - public static final int SHUTDOWN_REGISTRY = 15; + public static final int SHUTDOWN_NODE = 15; + public static final int SHUTDOWN_REGISTRY = 16; - public static final int PATCH_SERVER = 16; + public static final int PATCH_SERVER = 17; - public static final int ADD_OBJECT = 17; + public static final int ADD_OBJECT = 18; - static public final int ACTION_COUNT = 18; + static public final int ACTION_COUNT = 19; public boolean[] getAvailableActions() { @@ -88,6 +89,10 @@ public abstract class TreeNode extends TreeNodeBase { assert false; } + public void retrieveLog() + { + assert false; + } public void signal(String s) { assert false; |