1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
|
// **********************************************************************
//
// Copyright (c) 2003-2007 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 IceGridGUI.LiveDeployment;
import java.awt.Component;
import java.awt.Cursor;
import javax.swing.Icon;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import java.util.Enumeration;
import IceGrid.*;
import IceGridGUI.*;
class Server extends ListArrayTreeNode
{
//
// Actions
//
public boolean[] getAvailableActions()
{
boolean[] actions = new boolean[ACTION_COUNT];
if(_state != null)
{
actions[START] = _state == ServerState.Inactive && _enabled
&& !_resolver.substitute(_serverDescriptor.activation).equals("session");
actions[STOP] = _state != ServerState.Inactive;
actions[ENABLE] = !_enabled;
actions[DISABLE] = _enabled;
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("");
if(_state != ServerState.Inactive)
{
Node node = (Node)_parent;
if(!node.isRunningWindows())
{
for(int i = SIGHUP; i <= SIGTERM; ++i)
{
actions[i] = true;
}
}
}
}
return actions;
}
public void start()
{
final String prefix = "Starting server '" + _id + "'...";
getCoordinator().getStatusBar().setText(prefix);
AMI_Admin_startServer cb = new AMI_Admin_startServer()
{
//
// Called by another thread!
//
public void ice_response()
{
amiSuccess(prefix);
}
public void ice_exception(Ice.UserException e)
{
amiFailure(prefix, "Failed to start " + _id, e);
}
public void ice_exception(Ice.LocalException e)
{
amiFailure(prefix, "Failed to start " + _id, e.toString());
}
};
try
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
getCoordinator().getAdmin().startServer_async(cb, _id);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to start " + _id, e.toString());
}
finally
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
public void stop()
{
final String prefix = "Stopping server '" + _id + "'...";
getCoordinator().getStatusBar().setText(prefix);
AMI_Admin_stopServer cb = new AMI_Admin_stopServer()
{
//
// Called by another thread!
//
public void ice_response()
{
amiSuccess(prefix);
}
public void ice_exception(Ice.UserException e)
{
amiFailure(prefix, "Failed to stop " + _id, e);
}
public void ice_exception(Ice.LocalException e)
{
amiFailure(prefix, "Failed to stop " + _id, e.toString());
}
};
try
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
getCoordinator().getAdmin().stopServer_async(cb, _id);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to stop " + _id, e.toString());
}
finally
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
public void enable()
{
enableServer(true);
}
public void disable()
{
enableServer(false);
}
public void writeMessage()
{
if(_writeMessageDialog == null)
{
_writeMessageDialog = new WriteMessageDialog(getRoot());
}
_writeMessageDialog.showDialog(_id);
}
public void retrieveOutput(final boolean stdout)
{
getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory()
{
public FileIteratorPrx open(int count)
throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, DeploymentException
{
AdminSessionPrx adminSession = getRoot().getCoordinator().getSession();
if(stdout)
{
return adminSession.openServerStdOut(_id, count);
}
else
{
return adminSession.openServerStdErr(_id, count);
}
}
public String getTitle()
{
return "Server " + _id + " " + (stdout ? "stdout" : "stderr");
}
public String getDefaultFilename()
{
return _id + (stdout ? ".out" : ".err");
}
});
}
public void retrieveLog()
{
assert _serverDescriptor.logs.length > 0;
String path = null;
if(_serverDescriptor.logs.length == 1)
{
path = _resolver.substitute(_serverDescriptor.logs[0]);
}
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 = (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 + "'...";
getCoordinator().getStatusBar().setText(prefix);
AMI_Admin_sendSignal cb = new AMI_Admin_sendSignal()
{
//
// Called by another thread!
//
public void ice_response()
{
amiSuccess(prefix);
}
public void ice_exception(Ice.UserException e)
{
amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e);
}
public void ice_exception(Ice.LocalException e)
{
amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString());
}
};
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()
{
String message = _serverDescriptor.applicationDistrib ?
"You are about to install or refresh your"
+ " server distribution and your application distribution onto this node.\n"
+ "Do you want shut down all servers affected by this update?" :
"You are about to install or refresh the distribution for this server.\n"
+ "Do you want to shut down the server for this update?";
int shutdown = JOptionPane.showConfirmDialog(
getCoordinator().getMainFrame(),
message,
"Patch Confirmation",
JOptionPane.YES_NO_CANCEL_OPTION);
if(shutdown == JOptionPane.CANCEL_OPTION)
{
return;
}
final String prefix = "Patching server '" + _id + "'...";
getCoordinator().getStatusBar().setText(prefix);
AMI_Admin_patchServer cb = new AMI_Admin_patchServer()
{
//
// Called by another thread!
//
public void ice_response()
{
amiSuccess(prefix);
}
public void ice_exception(Ice.UserException e)
{
amiFailure(prefix, "Failed to patch " + _id, e);
}
public void ice_exception(Ice.LocalException e)
{
amiFailure(prefix, "Failed to patch " + _id, e.toString());
}
};
try
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
getCoordinator().getAdmin().
patchServer_async(cb, _id,
shutdown == JOptionPane.YES_OPTION);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to patch " + _id, e.toString());
}
finally
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
private void enableServer(boolean enable)
{
final String prefix = (enable ?
"Enabling" : "Disabling") + " server '" + _id + "'...";
final String action = enable ? "enable" : "disable";
getCoordinator().getStatusBar().setText(prefix);
AMI_Admin_enableServer cb = new AMI_Admin_enableServer()
{
//
// Called by another thread!
//
public void ice_response()
{
amiSuccess(prefix);
}
public void ice_exception(Ice.UserException e)
{
amiFailure(prefix, "Failed to " + action + " " + _id, e);
}
public void ice_exception(Ice.LocalException e)
{
amiFailure(prefix, "Failed to " + action + " " + _id, e.toString());
}
};
try
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
getCoordinator().getAdmin().enableServer_async(cb, _id, enable);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to " + action + " " + _id, e.toString());
}
finally
{
getCoordinator().getMainFrame().setCursor(
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
public JPopupMenu getPopupMenu()
{
LiveActions la = getCoordinator().getLiveActionsForPopup();
if(_popup == null)
{
_popup = new JPopupMenu();
_popup.add(la.get(START));
_popup.add(la.get(STOP));
_popup.addSeparator();
_popup.add(la.get(ENABLE));
_popup.add(la.get(DISABLE));
_popup.addSeparator();
_popup.add(la.get(PATCH_SERVER));
_popup.addSeparator();
_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();
_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));
}
la.setTarget(this);
_signalMenu.setEnabled(la.get(SIGHUP).isEnabled());
return _popup;
}
public Editor getEditor()
{
if(_editor == null)
{
_editor = new ServerEditor(getCoordinator());
}
_editor.show(this);
return _editor;
}
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
{
if(_cellRenderer == null)
{
//
// Initialization
//
_cellRenderer = new DefaultTreeCellRenderer();
//
// Regular servers
//
_icons = new Icon[8][2][2];
_icons[0][0][0] = Utils.getIcon("/icons/16x16/server_unknown.png");
_icons[ServerState.Inactive.value() + 1][0][0]
= Utils.getIcon("/icons/16x16/server_inactive.png");
_icons[ServerState.Activating.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_activating.png");
_icons[ServerState.ActivationTimedOut.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_activating.png");
_icons[ServerState.Active.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_active.png");
_icons[ServerState.Deactivating.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_deactivating.png");
_icons[ServerState.Destroying.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_destroying.png");
_icons[ServerState.Destroyed.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_destroyed.png");
//
// IceBox servers
//
_icons[0][1][0] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
_icons[ServerState.Inactive.value() + 1][1][0]
= Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
_icons[ServerState.Activating.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_activating.png");
_icons[ServerState.ActivationTimedOut.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_activating.png");
_icons[ServerState.Active.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_active.png");
_icons[ServerState.Deactivating.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_deactivating.png");
_icons[ServerState.Destroying.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_destroying.png");
_icons[ServerState.Destroyed.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_destroyed.png");
//
// Regular servers (disabled)
//
_icons[0][0][1] = Utils.getIcon("/icons/16x16/server_unknown.png");
_icons[ServerState.Inactive.value() + 1][0][1]
= Utils.getIcon("/icons/16x16/server_disabled_inactive.png");
_icons[ServerState.Activating.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_activating.png");
_icons[ServerState.ActivationTimedOut.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_activating.png");
_icons[ServerState.Active.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_active.png");
_icons[ServerState.Deactivating.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_deactivating.png");
_icons[ServerState.Destroying.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_destroying.png");
_icons[ServerState.Destroyed.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_destroyed.png");
//
// IceBox servers (disabled)
//
_icons[0][1][1] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
_icons[ServerState.Inactive.value() + 1][1][1]
= Utils.getIcon("/icons/16x16/icebox_server_disabled_inactive.png");
_icons[ServerState.Activating.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
_icons[ServerState.ActivationTimedOut.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
_icons[ServerState.Active.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_active.png");
_icons[ServerState.Deactivating.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_deactivating.png");
_icons[ServerState.Destroying.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_destroying.png");
_icons[ServerState.Destroyed.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_destroyed.png");
}
int icebox = _serverDescriptor instanceof IceBoxDescriptor ? 1 : 0;
int disabled = _enabled ? 0 : 1;
if(expanded)
{
_cellRenderer.setOpenIcon(_icons[_stateIconIndex][icebox][disabled]);
}
else
{
_cellRenderer.setClosedIcon(_icons[_stateIconIndex][icebox][disabled]);
}
_cellRenderer.setToolTipText(_toolTip);
return _cellRenderer.getTreeCellRendererComponent(
tree, value, sel, expanded, leaf, row, hasFocus);
}
Server(Node parent, String serverId, Utils.Resolver resolver,
ServerInstanceDescriptor instanceDescriptor,
ServerDescriptor serverDescriptor, ApplicationDescriptor application,
ServerState state, int pid, boolean enabled)
{
super(parent, serverId, 3);
_resolver = resolver;
_instanceDescriptor = instanceDescriptor;
_serverDescriptor = serverDescriptor;
_application = application;
_childrenArray[0] = _adapters;
_childrenArray[1] = _dbEnvs;
_childrenArray[2] = _services;
update(state, pid, enabled, false);
createAdapters();
createDbEnvs();
createServices();
}
ApplicationDescriptor getApplication()
{
return _application;
}
ServerInstanceDescriptor getInstanceDescriptor()
{
return _instanceDescriptor;
}
ServerDescriptor getServerDescriptor()
{
return _serverDescriptor;
}
ServerState getState()
{
return _state;
}
int getPid()
{
return _pid;
}
boolean isEnabled()
{
return _enabled;
}
Utils.Resolver getResolver()
{
return _resolver;
}
void rebuild(Server server)
{
_resolver = server._resolver;
_instanceDescriptor = server._instanceDescriptor;
_serverDescriptor = server._serverDescriptor;
_application = server._application;
_adapters = server._adapters;
_dbEnvs = server._dbEnvs;
_services = server._services;
_childrenArray[0] = _adapters;
_childrenArray[1] = _dbEnvs;
_childrenArray[2] = _services;
getRoot().getTreeModel().nodeStructureChanged(this);
}
void rebuild(Utils.Resolver resolver, boolean variablesChanged, java.util.Set serviceTemplates,
java.util.Set serverTemplates)
{
if(variablesChanged ||
(_instanceDescriptor != null && serverTemplates != null && serverTemplates.contains(_instanceDescriptor.template)))
{
if(_instanceDescriptor != null)
{
TemplateDescriptor templateDescriptor =
(TemplateDescriptor)_application.serverTemplates.get(_instanceDescriptor.template);
assert templateDescriptor != null;
_resolver.reset(resolver, _instanceDescriptor.parameterValues,
templateDescriptor.parameterDefaults);
_resolver.put("server", _id);
_serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
}
else
{
_resolver.reset(resolver);
_resolver.put("server", _id);
}
_adapters.clear();
createAdapters();
_dbEnvs.clear();
createDbEnvs();
_services.clear();
_servicePropertySets.clear();
createServices();
getRoot().getTreeModel().nodeStructureChanged(this);
}
else if(serviceTemplates != null && serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor)
{
_services.clear();
_servicePropertySets.clear();
createServices();
getRoot().getTreeModel().nodeStructureChanged(this);
}
}
void update(ServerState state, int pid, boolean enabled, boolean fireEvent)
{
if(state != _state || pid != _pid || enabled != _enabled)
{
_state = state;
_pid = pid;
_enabled = enabled;
_toolTip = toolTip(_state, _pid, _enabled);
if(_state == null)
{
_stateIconIndex = 0;
}
else
{
_stateIconIndex = _state.value() + 1;
}
if(fireEvent)
{
getRoot().getTreeModel().nodeChanged(this);
}
}
}
boolean updateAdapter(AdapterDynamicInfo info)
{
java.util.Iterator p = _adapters.iterator();
while(p.hasNext())
{
Adapter adapter = (Adapter)p.next();
if(adapter.update(info))
{
return true;
}
}
//
// Could be in one of the services as well
//
p = _services.iterator();
while(p.hasNext())
{
Service service = (Service)p.next();
if(service.updateAdapter(info))
{
return true;
}
}
return false;
}
int updateAdapters(java.util.List infoList)
{
int result = 0;
java.util.Iterator p = _adapters.iterator();
while(p.hasNext() && result < infoList.size())
{
Adapter adapter = (Adapter)p.next();
if(adapter.update(infoList))
{
result++;
}
}
//
// Could be in one of the services as well
//
p = _services.iterator();
while(p.hasNext() && result < infoList.size())
{
Service service = (Service)p.next();
result += service.updateAdapters(infoList);
}
return result;
}
void nodeDown()
{
update(null, 0, true, true);
java.util.Iterator p = _adapters.iterator();
while(p.hasNext())
{
Adapter adapter = (Adapter)p.next();
adapter.update((AdapterDynamicInfo)null);
}
p = _services.iterator();
while(p.hasNext())
{
Service service = (Service)p.next();
service.nodeDown();
}
}
java.util.SortedMap getProperties()
{
java.util.List psList = new java.util.LinkedList();
Node node = (Node)_parent;
psList.add(node.expand(_serverDescriptor.propertySet,
_application.name, _resolver));
if(_instanceDescriptor != null)
{
psList.add(node.expand(_instanceDescriptor.propertySet,
_application.name, _resolver));
}
return Utils.propertySetsToMap(psList, _resolver);
}
private void createAdapters()
{
java.util.Iterator p = _serverDescriptor.adapters.iterator();
while(p.hasNext())
{
AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
String adapterName = Utils.substitute(descriptor.name, _resolver);
String adapterId = Utils.substitute(descriptor.id, _resolver);
Ice.ObjectPrx proxy = null;
if(adapterId.length() > 0)
{
proxy = ((Node)_parent).getProxy(adapterId);
}
insertSortedChild(new Adapter(this, adapterName,
_resolver, adapterId, descriptor, proxy),
_adapters, null);
}
}
private void createDbEnvs()
{
java.util.Iterator p = _serverDescriptor.dbEnvs.iterator();
while(p.hasNext())
{
DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
String dbEnvName = Utils.substitute(descriptor.name, _resolver);
insertSortedChild(new DbEnv(this, dbEnvName, _resolver, descriptor),
_dbEnvs, null);
}
}
private void createServices()
{
if(_serverDescriptor instanceof IceBoxDescriptor)
{
if(_instanceDescriptor != null)
{
java.util.Iterator p = _instanceDescriptor.servicePropertySets.entrySet().iterator();
while(p.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
_servicePropertySets.put(_resolver.substitute((String)entry.getKey()), entry.getValue());
}
}
IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor;
java.util.Iterator p = iceBoxDescriptor.services.iterator();
while(p.hasNext())
{
ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)p.next();
createService(descriptor);
}
}
}
private void createService(ServiceInstanceDescriptor descriptor)
{
ServiceDescriptor serviceDescriptor = null;
String serviceName = null;
Utils.Resolver serviceResolver = null;
if(descriptor.template.length() > 0)
{
TemplateDescriptor templateDescriptor
= (TemplateDescriptor)_application.serviceTemplates.get(descriptor.template);
assert templateDescriptor != null;
serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
assert serviceDescriptor != null;
serviceResolver = new Utils.Resolver(_resolver,
descriptor.parameterValues,
templateDescriptor.parameterDefaults);
serviceName = serviceResolver.substitute(serviceDescriptor.name);
serviceResolver.put("service", serviceName);
}
else
{
serviceDescriptor = descriptor.descriptor;
assert serviceDescriptor != null;
serviceResolver = new Utils.Resolver(_resolver);
serviceName = _resolver.substitute(serviceDescriptor.name);
serviceResolver.put("service", serviceName);
}
PropertySetDescriptor serverInstancePSDescriptor =
(PropertySetDescriptor)_servicePropertySets.get(serviceName);
_services.add(new Service(this, serviceName, serviceResolver,
descriptor, serviceDescriptor, serverInstancePSDescriptor));
}
static private String toolTip(ServerState state, int pid, boolean enabled)
{
String result = (state == null ? "Unknown" : state.toString());
if(!enabled)
{
result += ", disabled";
}
if(pid != 0)
{
result += ", pid: " + pid;
}
return result;
}
private ServerInstanceDescriptor _instanceDescriptor;
private java.util.Map _servicePropertySets = new java.util.HashMap(); // with substituted names!
private ServerDescriptor _serverDescriptor;
private ApplicationDescriptor _application;
private Utils.Resolver _resolver;
private java.util.List _adapters = new java.util.LinkedList();
private java.util.List _dbEnvs = new java.util.LinkedList();
private java.util.List _services = new java.util.LinkedList();
private ServerState _state;
private boolean _enabled;
private int _stateIconIndex;
private int _pid;
private String _toolTip;
static private DefaultTreeCellRenderer _cellRenderer;
static private Icon[][][] _icons;
static private ServerEditor _editor;
static private JPopupMenu _popup;
static private JMenu _signalMenu;
static private WriteMessageDialog _writeMessageDialog;
}
|