summaryrefslogtreecommitdiff
path: root/java/src/IceGrid/TreeNode/Node.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceGrid/TreeNode/Node.java')
-rwxr-xr-xjava/src/IceGrid/TreeNode/Node.java181
1 files changed, 124 insertions, 57 deletions
diff --git a/java/src/IceGrid/TreeNode/Node.java b/java/src/IceGrid/TreeNode/Node.java
index 5509a613f36..0eac410dc48 100755
--- a/java/src/IceGrid/TreeNode/Node.java
+++ b/java/src/IceGrid/TreeNode/Node.java
@@ -112,6 +112,7 @@ class Node extends Parent
//
// Update the state of all adapters
//
+ /*
p = _adapters.entrySet().iterator();
while(p.hasNext())
{
@@ -121,7 +122,8 @@ class Node extends Parent
Ice.ObjectPrx proxy = (Ice.ObjectPrx)_adapterInfoMap.get(id);
adapter.updateProxy(proxy);
}
-
+ */
+
fireNodeChangedEvent(this);
}
@@ -143,28 +145,18 @@ class Node extends Parent
//
// Update the state of all adapters
//
+ /*
p = _adapters.values().iterator();
while(p.hasNext())
{
Adapter adapter = (Adapter)p.next();
adapter.updateProxy(null);
}
+ */
fireNodeChangedEvent(this);
}
-
- void updateServer(ServerDynamicInfo info)
- {
- //
- // NodeViewRoot updates the map
- //
- ServerInstance child = (ServerInstance)findChild(info.name);
- if(child != null)
- {
- child.updateDynamicInfo(info);
- }
- }
-
+
ServerDynamicInfo getServerDynamicInfo(String serverName)
{
if(_serverInfoMap == null)
@@ -184,73 +176,148 @@ class Node extends Parent
}
}
}
+
+ /*
+ ServerInstances(java.util.List descriptors,
+ Application application,
+ boolean fireEvent)
+ {
+ super("Server instances", application.getModel());
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ //
+ // The ServerInstance constructor inserts the new object in the
+ // node view model
+ //
+ ServerInstanceDescriptor descriptor =
+ (ServerInstanceDescriptor)p.next();
+
+
- void updateAdapter(AdapterDynamicInfo info)
+ String serverName = computeServerName(descriptor, application);
+
+ ServerInstance child = new ServerInstance(serverName,
+ descriptor,
+ application,
+ fireEvent);
+ addChild(child);
+ }
+ }
+
+ void update(java.util.List updates, String[] removeServers)
{
//
- // NodeViewRoot updates the map
+ // Note: _descriptors is updated by Application
//
- Adapter adapter = (Adapter)_adapters.get(info.id);
- if(adapter != null)
+
+ Application application = (Application)getParent(TreeModelI.APPLICATION_VIEW);
+
+ //
+ // One big set of removes
+ //
+ for(int i = 0; i < removeServers.length; ++i)
{
- adapter.updateProxy(info.proxy);
+ ServerInstance server = (ServerInstance)findChild(removeServers[i]);
+ server.removeFromNode();
}
- }
-
- Node(String applicationName, Model model, NodeDescriptor descriptor,
- java.util.Map serverInfoMap, java.util.Map adapterInfoMap)
- {
- super(descriptor.name, model);
- _serverInfoMap = serverInfoMap;
- _adapterInfoMap = adapterInfoMap;
- _applicationMap.put(applicationName, descriptor);
- }
+ removeChildren(removeServers);
- void addApplication(String applicationName, NodeDescriptor descriptor)
- {
- _applicationMap.put(applicationName, descriptor);
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+ java.util.Vector updatedChildren = new java.util.Vector();
+
+ java.util.Iterator p = updates.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor descriptor = (ServerInstanceDescriptor)p.next();
+
+ String serverName = computeServerName(descriptor, application);
+
+ ServerInstance child = (ServerInstance)findChild(serverName);
+ if(child == null)
+ {
+ newChildren.add(new ServerInstance(serverName, descriptor, application, true));
+ }
+ else
+ {
+ child.rebuild(application, descriptor, true);
+ updatedChildren.add(child);
+ }
+ }
+
+ updateChildren((CommonBaseI[])updatedChildren.toArray(new CommonBaseI[0]));
+ addChildren((CommonBaseI[])newChildren.toArray(new CommonBaseI[0]));
}
-
- //
- // Returns true when this node should be destroyed
- //
- boolean removeApplication(String applicationName)
+
+ void removeFromNodes()
{
- _applicationMap.remove(applicationName);
- return (_applicationMap.size() == 0);
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerInstance server = (ServerInstance)p.next();
+ server.removeFromNode();
+ }
}
- //
- // The node maintains a map adapter id => Adapter
- //
- Ice.ObjectPrx registerAdapter(String id, Adapter adapter)
+ static String computeServerName(ServerInstanceDescriptor instanceDescriptor,
+ Application application)
{
- _adapters.put(id, adapter);
- Ice.ObjectPrx result = null;
- if(_adapterInfoMap != null)
+ String nodeName = instanceDescriptor.node;
+
+ if(instanceDescriptor.template.length() > 0)
{
- result = (Ice.ObjectPrx)_adapterInfoMap.get(id);
+ //
+ // Can't be null
+ //
+ TemplateDescriptor templateDescriptor =
+ application.findServerTemplateDescriptor(instanceDescriptor.template);
+
+ java.util.Map parameters =
+ Utils.substituteVariables(instanceDescriptor.parameterValues,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
+
+ return Utils.substituteVariables(templateDescriptor.descriptor.name,
+ parameters,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
+ }
+ else
+ {
+
+ return Utils.substituteVariables(instanceDescriptor.descriptor.name,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
}
- return result;
}
- void unregisterAdapter(String id)
+ */
+
+
+ java.util.Map getVariables()
{
- _adapters.remove(id);
+ return null;
}
- private java.util.Map _applicationMap = new java.util.HashMap();
+
+ Node(String applicationName, Model model,
+ String nodeName, NodeDescriptor descriptor,
+ java.util.Map serverInfoMap, java.util.Map adapterInfoMap)
+ {
+ super(nodeName, model);
+ _serverInfoMap = serverInfoMap;
+ _adapterInfoMap = adapterInfoMap;
+ }
private java.util.Map _serverInfoMap;
private java.util.Map _adapterInfoMap;
- //
- // Adapter id => Adapter
- //
- private java.util.Map _adapters = new java.util.HashMap();
-
-
static private DefaultTreeCellRenderer _cellRenderer;
static private Icon _nodeUpOpen;
static private Icon _nodeUpClosed;