}
private boolean checkServerActive(String host, int port, byte []object_key, boolean enp_reused)
{
ClientConnectionManager cm = null;
IIOPAddress address = null;
ClientConnection connection = null;
LocateRequestOutputStream lros = null;
LocateReplyReceiver receiver = null;
LocateReplyInputStream lris = null;
boolean result = false;
cm = ((org.jacorb.orb.ORB)orb).getClientConnectionManager ();
try
{
address = new IIOPAddress (host, port);
address.configure(configuration);
IIOPProfile iiopProfile = new IIOPProfile(address, object_key, ((org.jacorb.orb.ORB)orb).getGIOPMinorVersion());
iiopProfile.configure(configuration);
connection = cm.getConnection(iiopProfile);
}
catch(ConfigurationException e)
{
logger.error("Failed to configure", e);
}
if (this.logger.isDebugEnabled())
{
this.logger.debug("Pinging " + host + " / " + port);
}
try
{
lros = new LocateRequestOutputStream ( orb, object_key, connection.getId(), 2);
receiver = new LocateReplyReceiver();
receiver.configure (configuration);
connection.sendRequest(
lros,
receiver,
lros.getRequestId (),
true ); // response expected
lris = receiver.getReply();
switch (lris.rep_hdr.locate_status.value ())
{
case LocateStatusType_1_2._UNKNOWN_OBJECT:
case LocateStatusType_1_2._LOC_SYSTEM_EXCEPTION:
{
SystemException se = SystemExceptionHelper.read( lris );
if (enp_reused && (se instanceof org.omg.CORBA.OBJECT_NOT_EXIST))
{
// Endpoint is reused by another server and the new server
// returned OBJECT_NOT_EXIST, so give up using this endpoint.
// The return value can be interpreted as not available endpoint.
result = false;
}
else
{
result = true;
}
break;
}
case LocateStatusType_1_2._OBJECT_HERE:
case LocateStatusType_1_2._OBJECT_FORWARD:
case LocateStatusType_1_2._OBJECT_FORWARD_PERM:
case LocateStatusType_1_2._LOC_NEEDS_ADDRESSING_MODE:
default:
{
result = true;
break;
}
}
}
catch (Throwable ex)
{
this.logger.debug("Exception while checking server active", ex);
result = false;
}
finally
{
cm.releaseConnection (connection);
}
return result;
}