}
private ICosMonitoredThread get_active_corba_server(CorbaServerStruct server)
{
//try to use local reference if the local corba server is in CONTROL
ICosMonitoredThread serverRef = null;
if (server.operationMode == CosOperationModeEnum.OperControl
&& server.reference != null)
{
serverRef = server.reference;
//validate it
try
{
serverRef.cosPollControl();
}
catch (Exception ex)
{
//ignore. just reset the reference
logger_.trace("Can not poll control local corba server.");
serverRef = null;
}
}
//if the local server is not suitable, try to get from peers. always use the first one found
if (serverRef == null)
{
Iterator<PeerManagerStruct> it = activePeers_.values().iterator();
while(it.hasNext() && serverRef == null)
{
//precautions
if (it.next().reference == null)
continue;
//get from peer and validate it
try
{
serverRef = it.next().reference.cosGetCorbaServer(server.key);
if (serverRef != null)
{
serverRef.cosPollControl();
}
it.next().errorCounter = 0;
}
catch(CosUnknownProcessException ue)
{