home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
csbrokersn.tcl
< prev
next >
Wrap
Text File
|
1996-10-25
|
3KB
|
135 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)csbrokersn.tcl /main/hindenburg/11
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)csbrokersn.tcl /main/hindenburg/11 25 Oct 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require csbrokerno.tcl
# End user added include file section
require "csnode.tcl"
Class CSBrokersNode : {CSNode} {
constructor
method destructor
method childName
method childObjects
method createChild
method shutdown
method doUpdate
attribute brokerCount
attribute badBrokerCount
}
constructor CSBrokersNode {class this name} {
set this [CSNode::constructor $class $this $name]
# Start constructor user section
$this brokerCount 0
$this badBrokerCount 0
$this label "<brokers>"
$this icon rep_brokers_16
$this canShutdown 1
# End constructor user section
return $this
}
method CSBrokersNode::destructor {this} {
# Start destructor user section
# End destructor user section
$this CSNode::destructor
}
method CSBrokersNode::childName {this object} {
return [$object name]
}
method CSBrokersNode::childObjects {this} {
set goodBrokers {}
set badBrokerCount 0
set brokerCount 0
set ns [ORB::nameServer]
foreach broker [$ns brokers] {
if ![catch {$broker host} error] {
lappend goodBrokers $broker
} else {
lappend brokerErrors $error
incr badBrokerCount
}
incr brokerCount
}
$this brokerCount $brokerCount
$this badBrokerCount $badBrokerCount
if [info exists brokerErrors] {
[$this view] warning "Could not access all brokers due to\
errors:\n\n[join $brokerErrors "\n\n"]"
}
return [osort name $goodBrokers]
}
method CSBrokersNode::createChild {this object} {
return [CSBrokerNode new $this.[$this childName $object] $object]
}
method CSBrokersNode::shutdown {this {confirm 1}} {
if $confirm {
$this confirmShutdown "Shutdown All Brokers" \
"Are you sure you want to shutdown all brokers?" shutdownBrokers
return
}
# Shutdown all brokers.
#
set shutdownCount 0
set ns [ORB::nameServer]
set nsBroker [$ns broker]
set nsShutdown 0
foreach broker [$ns brokers] {
if [catch {$broker shutdown} shutdownError] {
[$this view] error $shutdownError
} else {
incr shutdownCount
# If name_server broker was shutdown, don't try to update,
# since that will time-out for sure.
#
if {$broker == $nsBroker} {
set nsShutdown 1
}
}
}
if $nsShutdown {
$this removeChildren
} elseif {$shutdownCount > 0} {
$this update 0
}
}
method CSBrokersNode::doUpdate {this {rebuild 1}} {
$this CSNode::doUpdate $rebuild
set info [$this info]
$info addHeader "Running Brokers"
$info addItem "Number of brokers" [$this brokerCount]
if {[$this badBrokerCount] > 0} {
$info addItem "Number of not responding brokers" [$this badBrokerCount]
}
}
# Do not delete this line -- regeneration end marker