}
}
}
int retryCount = 0;
SocketException sockEx = null;
for (; retryCount < numberOfCallRetries; retryCount++)
{
// timeLeft < 0 will indicate that there is no per invocation timeout.
int timeLeft = -1;
if (0 < tempTimeout)
{
// If a per invocation timeout has been set, the time spent retrying
// should count toward the elapsed time.
timeLeft = (int) (tempTimeout - (System.currentTimeMillis() - start));
if (timeLeft <= 0)
break;
}
try
{
socketWrapper = getConnection(marshaller, unmarshaller, timeLeft);
}
catch (Exception e)
{
// if (bailOut)
// return null;
semaphore.release();
if (trace) log.trace(this + " released semaphore: " + semaphore.permits());
throw new CannotConnectException(
"Can not get connection to server. Problem establishing " +
"socket connection for " + locator, e);
}
if (tempTimeout >= 0)
{
savedTimeout = socketWrapper.getTimeout();
socketWrapper.setTimeout((int) (tempTimeout - (System.currentTimeMillis() - start)));
}
long end = System.currentTimeMillis() - start;
getSocketTime += end;
try
{
int version = Version.getDefaultVersion();
boolean performVersioning = Version.performVersioning();
OutputStream outputStream = socketWrapper.getOutputStream();
if (performVersioning)
{
writeVersion(outputStream, version);
}
//TODO: -TME so this is messed up as now ties remoting versioning to using a marshaller type
versionedWrite(outputStream, marshaller, invocation, version);
end = System.currentTimeMillis() - start;
writeTime += end;
start = System.currentTimeMillis();
if (oneway)
{
if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning null"); }
}
else
{
InputStream inputStream = socketWrapper.getInputStream();
if (performVersioning)
{
version = readVersion(inputStream);
if (version == -1)
{
throw new SocketException("end of file");
}
if (version == SocketWrapper.CLOSING)
{
log.debug("Received version 254: treating as end of file");
throw new SocketException("end of file");
}
}
response = versionedRead(inputStream, unmarshaller, version);
}