summaryrefslogtreecommitdiff
path: root/java/src/IceGrid/TreeNode/ReplicaGroups.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-10-13 00:06:05 +0000
committerBernard Normier <bernard@zeroc.com>2005-10-13 00:06:05 +0000
commitae1e4261cf8a63b87fa07ebf607ce3da625fe274 (patch)
tree9e409c2ed6853c77d6c36f4e4beb9667278e09b9 /java/src/IceGrid/TreeNode/ReplicaGroups.java
parentDbEnv editor + cleanup (diff)
downloadice-ae1e4261cf8a63b87fa07ebf607ce3da625fe274.tar.bz2
ice-ae1e4261cf8a63b87fa07ebf607ce3da625fe274.tar.xz
ice-ae1e4261cf8a63b87fa07ebf607ce3da625fe274.zip
Fixed IceGrid build; replicated adapter is now replica group
Diffstat (limited to 'java/src/IceGrid/TreeNode/ReplicaGroups.java')
-rwxr-xr-xjava/src/IceGrid/TreeNode/ReplicaGroups.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/java/src/IceGrid/TreeNode/ReplicaGroups.java b/java/src/IceGrid/TreeNode/ReplicaGroups.java
new file mode 100755
index 00000000000..1ef6b629493
--- /dev/null
+++ b/java/src/IceGrid/TreeNode/ReplicaGroups.java
@@ -0,0 +1,105 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+package IceGrid.TreeNode;
+
+import javax.swing.AbstractListModel;
+
+import IceGrid.ReplicaGroupDescriptor;
+import IceGrid.Model;
+import IceGrid.Utils;
+
+class ReplicaGroups extends EditableParent
+{
+ static public java.util.LinkedList
+ copyDescriptors(java.util.List descriptors)
+ {
+ java.util.LinkedList copy = new java.util.LinkedList();
+ java.util.Iterator p = descriptors.iterator();
+ while(p.hasNext())
+ {
+ copy.add(ReplicaGroup.copyDescriptor(
+ (ReplicaGroupDescriptor)p.next()));
+ }
+ return copy;
+ }
+
+ ReplicaGroups(java.util.List descriptors, Model model)
+ throws UpdateFailedException
+ {
+ super(false, "Replica Groups", model);
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroupDescriptor descriptor
+ = (ReplicaGroupDescriptor)p.next();
+
+ addChild(new ReplicaGroup(false, descriptor, _model));
+ }
+ }
+
+ java.util.LinkedList getUpdates()
+ {
+ java.util.LinkedList updates = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroup ra = (ReplicaGroup)p.next();
+ if(ra.isNew() || ra.isModified())
+ {
+ updates.add(ra.getDescriptor());
+ }
+ }
+ return updates;
+ }
+
+ void update(java.util.List descriptors, String[] removeAdapters)
+ throws UpdateFailedException
+ {
+ _descriptors = descriptors;
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removeAdapters);
+
+ //
+ // 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 = descriptors.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)p.next();
+
+ ReplicaGroup child
+ = (ReplicaGroup)findChild(descriptor.id);
+ if(child == null)
+ {
+ newChildren.add(new ReplicaGroup(false, descriptor,
+ _model));
+ }
+ else
+ {
+ child.rebuild(descriptor);
+ updatedChildren.add(child);
+ }
+ }
+
+ updateChildren((CommonBaseI[])updatedChildren.toArray
+ (new CommonBaseI[0]));
+ addChildren((CommonBaseI[])newChildren.toArray(new CommonBaseI[0]));
+ }
+
+ private java.util.List _descriptors;
+}