diff options
Diffstat (limited to 'java/src')
-rwxr-xr-x | java/src/IceGrid/ListDialog.java | 2 | ||||
-rwxr-xr-x | java/src/IceGrid/Model.java | 38 | ||||
-rwxr-xr-x | java/src/IceGrid/ParametersDialog.java | 2 | ||||
-rwxr-xr-x | java/src/IceGrid/TableDialog.java | 2 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Application.java | 25 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Node.java | 145 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/NodeEditor.java | 35 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Server.java | 2 |
8 files changed, 223 insertions, 28 deletions
diff --git a/java/src/IceGrid/ListDialog.java b/java/src/IceGrid/ListDialog.java index a1d8943e6da..e9ee2cff37d 100755 --- a/java/src/IceGrid/ListDialog.java +++ b/java/src/IceGrid/ListDialog.java @@ -38,7 +38,7 @@ public class ListDialog extends JDialog {
public ListDialog(Frame parentFrame, String title, boolean trim)
{
- super(parentFrame, title, true);
+ super(parentFrame, title + " - IceGrid Admin", true);
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
_trim = trim;
diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java index 9ec72625743..1b88cd16004 100755 --- a/java/src/IceGrid/Model.java +++ b/java/src/IceGrid/Model.java @@ -343,6 +343,7 @@ public class Model {
assert(_latestSerial == -1);
_latestSerial = serial;
+ System.err.println("Registry init: serial == " + _latestSerial);
_root.init(applications);
}
@@ -388,10 +389,12 @@ public class Model boolean proceedWithUpdate(int serial)
{
- if(serial <= _latestSerial)
+ System.err.println("Proceed with update serial == " + serial);
+
+ if(_latestSerial == -1 || serial <= _latestSerial)
{
//
- // Ignore old messages
+ // Ignore old messages and messages when we're logged out
//
return false;
}
@@ -472,7 +475,14 @@ public class Model if(path != null)
{
CommonBase newNode = findNewNode(path);
- _tree.setSelectionPath(newNode.getPath());
+ if(newNode == getSelectedNode())
+ {
+ refreshDisplay();
+ }
+ else
+ {
+ _tree.setSelectionPath(newNode.getPath());
+ }
}
}
@@ -497,6 +507,7 @@ public class Model {
_mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
_writeSerial = _sessionKeeper.getSession().startUpdate();
+ System.err.println("New write serial == " + _writeSerial);
}
catch(AccessDeniedException e)
{
@@ -602,6 +613,9 @@ public class Model private boolean saveUpdates()
{
+ System.err.println("write serial == " + _writeSerial);
+ System.err.println("latest serial == " + _latestSerial);
+
assert _writeSerial == _latestSerial;
_mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
@@ -618,6 +632,11 @@ public class Model _sessionKeeper.getSession().addApplication(
(ApplicationDescriptor)application.getDescriptor());
application.commit();
+ //
+ // Will ignore this update
+ //
+ _latestSerial++;
+ _writeSerial = _latestSerial;
}
else
{
@@ -627,14 +646,13 @@ public class Model {
_sessionKeeper.getSession().updateApplication(updateDescriptor);
application.commit();
+ //
+ // Will ignore this update
+ //
+ _latestSerial++;
+ _writeSerial = _latestSerial;
}
}
-
- //
- // Will ignore these updates
- //
- _latestSerial++;
- _writeSerial = _latestSerial;
}
catch(AccessDeniedException e)
{
@@ -750,6 +768,8 @@ public class Model {
_latestSerial = -1;
_writeSerial = -1;
+ _admin = null;
+ showActions();
_logout.setEnabled(false);
}
diff --git a/java/src/IceGrid/ParametersDialog.java b/java/src/IceGrid/ParametersDialog.java index 157ac416266..7ed56a5e142 100755 --- a/java/src/IceGrid/ParametersDialog.java +++ b/java/src/IceGrid/ParametersDialog.java @@ -47,7 +47,7 @@ public class ParametersDialog extends JDialog String valHeading, boolean editNames,
final String nullLabel)
{
- super(parentFrame, title, true);
+ super(parentFrame, title + " - IceGrid Admin", true);
_editNames = editNames;
_nullObject = new Object()
{
diff --git a/java/src/IceGrid/TableDialog.java b/java/src/IceGrid/TableDialog.java index 52692c38057..b9fc97a4399 100755 --- a/java/src/IceGrid/TableDialog.java +++ b/java/src/IceGrid/TableDialog.java @@ -40,7 +40,7 @@ public class TableDialog extends JDialog public TableDialog(Frame parentFrame, String title,
String heading0, String heading1, boolean editKeys)
{
- super(parentFrame, title, true);
+ super(parentFrame, title + " - IceGrid Admin", true);
_editKeys = editKeys;
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
diff --git a/java/src/IceGrid/TreeNode/Application.java b/java/src/IceGrid/TreeNode/Application.java index 8d854089534..204ba0c50f9 100755 --- a/java/src/IceGrid/TreeNode/Application.java +++ b/java/src/IceGrid/TreeNode/Application.java @@ -91,7 +91,7 @@ public class Application extends EditableParent {
actions[PASTE] = descriptor instanceof ApplicationDescriptor;
}
- if(!_model.isUpdateInProgress())
+ if(!_model.isUpdateInProgress() && _model.getAdmin() != null)
{
actions[APPLICATION_INSTALL_DISTRIBUTION] =
!_descriptor.distrib.icepatch.equals("");
@@ -324,7 +324,26 @@ public class Application extends EditableParent update.removeNodes = _nodes.removedElements();
update.nodes = _nodes.getUpdates();
- return update;
+
+ //
+ // Return null if nothing changed
+ //
+ if(!isModified() &&
+ update.removeReplicaGroups.length == 0 &&
+ update.replicaGroups.size() == 0 &&
+ update.removeServerTemplates.length == 0 &&
+ update.serverTemplates.size() == 0 &&
+ update.removeServiceTemplates.length == 0 &&
+ update.serviceTemplates.size() == 0 &&
+ update.removeNodes.length == 0 &&
+ update.nodes.size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return update;
+ }
}
public void commit()
@@ -499,6 +518,7 @@ public class Application extends EditableParent if(desc.description != null)
{
_descriptor.description = desc.description.value;
+ _origDescription = _descriptor.description;
}
//
@@ -516,6 +536,7 @@ public class Application extends EditableParent if(desc.distrib != null)
{
_descriptor.distrib = desc.distrib.value;
+ _origDistrib = _descriptor.distrib;
}
//
diff --git a/java/src/IceGrid/TreeNode/Node.java b/java/src/IceGrid/TreeNode/Node.java index 75e7bad94d9..fc70ca311be 100755 --- a/java/src/IceGrid/TreeNode/Node.java +++ b/java/src/IceGrid/TreeNode/Node.java @@ -15,13 +15,19 @@ import javax.swing.Icon; import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
+import javax.swing.JTextField;
import javax.swing.JTree;
+import javax.swing.SwingUtilities;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.DefaultTreeCellRenderer;
+import java.text.NumberFormat;
+
+import IceGrid.AMI_Admin_getNodeLoad;
import IceGrid.AMI_Admin_shutdownNode;
+import IceGrid.LoadInfo;
import IceGrid.NodeDescriptor;
import IceGrid.NodeInfo;
import IceGrid.Model;
@@ -85,7 +91,7 @@ class Node extends EditableParent actions[NEW_SERVER] = true;
actions[NEW_SERVER_ICEBOX] = true;
actions[NEW_SERVER_FROM_TEMPLATE] = true;
- actions[SHUTDOWN_NODE] = _up;
+ actions[SHUTDOWN_NODE] = _up && _model.getAdmin() != null;
}
return actions;
}
@@ -568,6 +574,7 @@ class Node extends EditableParent {
_up = true;
_staticInfo = staticInfo;
+ _windows = _staticInfo.os.toLowerCase().startsWith("windows");
fireNodeChangedEvent(this);
}
@@ -586,6 +593,103 @@ class Node extends EditableParent }
}
+ void getLoad()
+ {
+ AMI_Admin_getNodeLoad cb = new AMI_Admin_getNodeLoad()
+ {
+ public void ice_response(LoadInfo loadInfo)
+ {
+ NumberFormat format;
+ if(_windows)
+ {
+ format = NumberFormat.getPercentInstance();
+ format.setMaximumFractionDigits(1);
+ format.setMinimumFractionDigits(1);
+ }
+ else
+ {
+ format = NumberFormat.getNumberInstance();
+ format.setMaximumFractionDigits(2);
+ format.setMinimumFractionDigits(2);
+ }
+
+ final String load =
+ format.format(loadInfo.avg1) + " " +
+ format.format(loadInfo.avg5) + " " +
+ format.format(loadInfo.avg15);
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _editor.setLoad(load, Node.this);
+ }
+ });
+ }
+
+ public void ice_exception(final Ice.UserException e)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if(e instanceof IceGrid.NodeNotExistException)
+ {
+ _editor.setLoad(
+ "Error: this node is not known to the IceGrid Registry",
+ Node.this);
+ }
+ else if(e instanceof IceGrid.NodeUnreachableException)
+ {
+ _editor.setLoad("Error: cannot reach this node", Node.this);
+ }
+ else
+ {
+ _editor.setLoad("Error: " + e.toString(), Node.this);
+ }
+ }
+ });
+ }
+
+ public void ice_exception(final Ice.LocalException e)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _editor.setLoad("Error: " + e.toString(), Node.this);
+ }
+ });
+ }
+ };
+
+ try
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ IceGrid.AdminPrx admin = _model.getAdmin();
+ if(admin == null)
+ {
+ _editor.setLoad("Unknown", this);
+ }
+ else
+ {
+ admin.getNodeLoad_async(cb, _id);
+ }
+ }
+ catch(Ice.LocalException e)
+ {
+ _editor.setLoad("Error: " + e.toString(), this);
+ }
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+
NodeUpdateDescriptor getUpdate()
{
NodeUpdateDescriptor update = new NodeUpdateDescriptor();
@@ -642,6 +746,11 @@ class Node extends EditableParent }
else
{
+ if(!_descriptor.description.equals(_origDescription))
+ {
+ update.description = new IceGrid.BoxedString(_descriptor.description);
+ }
+
if(!_descriptor.loadFactor.equals(_origLoadFactor))
{
update.loadFactor = new IceGrid.BoxedString(_descriptor.loadFactor);
@@ -684,11 +793,21 @@ class Node extends EditableParent throws UpdateFailedException
{
//
+ // Description
+ //
+ if(update.description != null)
+ {
+ _descriptor.description = update.description.value;
+ _origDescription = _descriptor.description;
+ }
+
+ //
// Load factor
//
if(update.loadFactor != null)
{
_descriptor.loadFactor = update.loadFactor.value;
+ _origLoadFactor = _descriptor.loadFactor;
}
//
@@ -818,11 +937,10 @@ class Node extends EditableParent public void commit()
{
super.commit();
- if(_descriptor != null)
- {
- _origVariables = (java.util.Map)_descriptor.variables.clone();
- _origLoadFactor = _descriptor.loadFactor;
- }
+
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
+ _origLoadFactor = _descriptor.loadFactor;
}
Node(boolean brandNew, String nodeName, NodeDescriptor descriptor,
@@ -834,6 +952,10 @@ class Node extends EditableParent _inRegistry = (descriptor != null);
_staticInfo = staticInfo;
_up = staticInfo != null;
+ if(_up)
+ {
+ _windows = _staticInfo.os.toLowerCase().startsWith("windows");
+ }
if(!_inRegistry)
{
@@ -846,10 +968,10 @@ class Node extends EditableParent }
_descriptor = descriptor;
- _origVariables = (java.util.Map)_descriptor.variables.clone();
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
_origLoadFactor = _descriptor.loadFactor;
-
_resolver = new Utils.Resolver(new java.util.Map[]
{_descriptor.variables, application.getVariables()});
@@ -985,6 +1107,11 @@ class Node extends EditableParent return _staticInfo;
}
+ boolean isRunningWindows()
+ {
+ return _windows;
+ }
+
void tryAdd(ServerInstanceDescriptor instanceDescriptor,
ServerDescriptor serverDescriptor,
boolean addDescriptor) throws UpdateFailedException
@@ -1136,6 +1263,7 @@ class Node extends EditableParent private Utils.Resolver _resolver;
private java.util.Map _origVariables;
+ private String _origDescription;
private String _origLoadFactor;
private boolean _up = false;
@@ -1144,6 +1272,7 @@ class Node extends EditableParent private boolean _inRegistry;
private NodeInfo _staticInfo;
+ private boolean _windows;
static private DefaultTreeCellRenderer _cellRenderer;
static private Icon _nodeUp;
diff --git a/java/src/IceGrid/TreeNode/NodeEditor.java b/java/src/IceGrid/TreeNode/NodeEditor.java index 236a6291a9e..5fa7e79f0df 100755 --- a/java/src/IceGrid/TreeNode/NodeEditor.java +++ b/java/src/IceGrid/TreeNode/NodeEditor.java @@ -9,6 +9,7 @@ package IceGrid.TreeNode;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -20,6 +21,7 @@ import javax.swing.JOptionPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import javax.swing.KeyStroke;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.CellConstraints;
@@ -171,6 +173,17 @@ class NodeEditor extends Editor _machineType.setEditable(false);
_loadAverage.setEditable(false);
+ Action refresh = new AbstractAction("Refresh")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Node node = (Node)_target;
+ node.getLoad();
+ }
+ };
+ _refreshButton = new JButton(refresh);
+
+
//
// Variables
//
@@ -224,19 +237,30 @@ class NodeEditor extends Editor + " CPU"
+ (info.nProcessors >= 2 ? "s" : ""));
- if(info.os.toLowerCase().startsWith("windows"))
+ if(node.isRunningWindows())
{
_loadAverageLabel.setText("CPU Usage");
- _loadAverage.setText("92% 48% 18%");
}
else
{
_loadAverageLabel.setText("Load Average");
- _loadAverage.setText("0.92 0.48 0.18");
}
+ _loadAverage.setText("Refreshing...");
+ node.getLoad();
}
}
+ void setLoad(String load, Node node)
+ {
+ if(node == _target)
+ {
+ _loadAverage.setText(load);
+ }
+ //
+ // Otherwise, we've already moved to another node
+ //
+ }
+
void appendCurrentStatus(DefaultFormBuilder builder)
{
@@ -248,8 +272,8 @@ class NodeEditor extends Editor builder.nextLine();
builder.append("Machine Type");
builder.append(_machineType, 3);
- builder.append(_loadAverageLabel);
- builder.append(_loadAverage, 3);
+ builder.append(_loadAverageLabel, _loadAverage);
+ builder.append(_refreshButton);
builder.nextLine();
}
@@ -360,4 +384,5 @@ class NodeEditor extends Editor private JTextField _machineType = new JTextField(20);
private JLabel _loadAverageLabel = new JLabel();
private JTextField _loadAverage = new JTextField(20);
+ private JButton _refreshButton;
}
diff --git a/java/src/IceGrid/TreeNode/Server.java b/java/src/IceGrid/TreeNode/Server.java index 9d10b23143e..7410d2b8301 100755 --- a/java/src/IceGrid/TreeNode/Server.java +++ b/java/src/IceGrid/TreeNode/Server.java @@ -180,7 +180,7 @@ class Server extends EditableParent }
ServerState state = getState();
- if(state != null)
+ if(state != null && _model.getAdmin() != null)
{
actions[START] = state == ServerState.Inactive && _enabled;
actions[STOP] = state != ServerState.Inactive;
|