summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-09-05 14:44:03 -0230
committerDwayne Boone <dwayne@zeroc.com>2007-09-05 14:44:03 -0230
commitbdcf4f222f50b915d2dfc0ea3960758adf6937db (patch)
treee263a048b6297395c97e860c87a0ca27b569cb08 /java
parentAdded missing file (diff)
downloadice-bdcf4f222f50b915d2dfc0ea3960758adf6937db.tar.bz2
ice-bdcf4f222f50b915d2dfc0ea3960758adf6937db.tar.xz
ice-bdcf4f222f50b915d2dfc0ea3960758adf6937db.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1351 - use monotonic timers where possible
Diffstat (limited to 'java')
-rw-r--r--java/jdk/1.4/IceInternal/Time.java4
-rw-r--r--java/jdk/1.5/IceInternal/Time.java4
-rw-r--r--java/src/Freeze/BackgroundSaveEvictorI.java18
-rw-r--r--java/src/Freeze/TransactionalEvictorContext.java2
-rw-r--r--java/src/Freeze/TransactionalEvictorI.java2
-rw-r--r--java/src/Ice/ConnectionI.java22
-rw-r--r--java/src/IceInternal/LocatorTable.java7
-rw-r--r--java/src/IceInternal/OutgoingAsync.java4
-rw-r--r--java/src/IceInternal/TcpTransceiver.java8
9 files changed, 36 insertions, 35 deletions
diff --git a/java/jdk/1.4/IceInternal/Time.java b/java/jdk/1.4/IceInternal/Time.java
index e0eced23e49..0f149ebc057 100644
--- a/java/jdk/1.4/IceInternal/Time.java
+++ b/java/jdk/1.4/IceInternal/Time.java
@@ -11,7 +11,7 @@ package IceInternal;
final public class Time
{
- static long
+ static public long
currentMonotonicTimeMillis()
{
//
@@ -20,4 +20,4 @@ final public class Time
//
return System.currentTimeMillis();
}
-}; \ No newline at end of file
+};
diff --git a/java/jdk/1.5/IceInternal/Time.java b/java/jdk/1.5/IceInternal/Time.java
index 6c5be83e920..d77879ef836 100644
--- a/java/jdk/1.5/IceInternal/Time.java
+++ b/java/jdk/1.5/IceInternal/Time.java
@@ -11,9 +11,9 @@ package IceInternal;
final public class Time
{
- static long
+ static public long
currentMonotonicTimeMillis()
{
return System.nanoTime() / 1000000;
}
-}; \ No newline at end of file
+};
diff --git a/java/src/Freeze/BackgroundSaveEvictorI.java b/java/src/Freeze/BackgroundSaveEvictorI.java
index dc27914731f..e5accc6bc79 100644
--- a/java/src/Freeze/BackgroundSaveEvictorI.java
+++ b/java/src/Freeze/BackgroundSaveEvictorI.java
@@ -68,7 +68,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
{
if(_active)
{
- startTime = System.currentTimeMillis();
+ startTime = IceInternal.Time.currentMonotonicTimeMillis();
wait(_timeout);
}
else
@@ -88,7 +88,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
//
// Did we timeout?
//
- if(System.currentTimeMillis() - startTime >= _timeout)
+ if(IceInternal.Time.currentMonotonicTimeMillis() - startTime >= _timeout)
{
_communicator.getLogger().error(_errorPrefix +
"Fatal error: streaming watch dog thread timed out.");
@@ -276,7 +276,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
ObjectRecord rec = element.rec;
rec.servant = servant;
- rec.stats.creationTime = System.currentTimeMillis();
+ rec.stats.creationTime = IceInternal.Time.currentMonotonicTimeMillis();
rec.stats.lastSaveTime = 0;
rec.stats.avgSaveTime = 0;
@@ -985,9 +985,9 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
}
else
{
- long preSave = System.currentTimeMillis();
+ long preSave = IceInternal.Time.currentMonotonicTimeMillis();
wait(_savePeriod);
- if(System.currentTimeMillis() > preSave + _savePeriod)
+ if(IceInternal.Time.currentMonotonicTimeMillis() > preSave + _savePeriod)
{
break;
}
@@ -1028,7 +1028,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
java.util.List streamedObjectQueue = new java.util.ArrayList();
- long streamStart = System.currentTimeMillis();
+ long streamStart = IceInternal.Time.currentMonotonicTimeMillis();
//
// Stream each element
@@ -1146,7 +1146,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
if(_trace >= 1)
{
- long now = System.currentTimeMillis();
+ long now = IceInternal.Time.currentMonotonicTimeMillis();
_communicator.getLogger().trace("Freeze.Evictor", "streamed " + streamedObjectQueue.size() +
" objects in " + (now - streamStart) + " ms");
}
@@ -1178,7 +1178,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
txSize = streamedObjectQueue.size();
}
- long saveStart = System.currentTimeMillis();
+ long saveStart = IceInternal.Time.currentMonotonicTimeMillis();
String txnId = null;
try
@@ -1231,7 +1231,7 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
if(_trace >= 1)
{
- long now = System.currentTimeMillis();
+ long now = IceInternal.Time.currentMonotonicTimeMillis();
_communicator.getLogger().trace("Freeze.Evictor", "saved " + txSize + " objects in " +
(now - saveStart) + " ms");
}
diff --git a/java/src/Freeze/TransactionalEvictorContext.java b/java/src/Freeze/TransactionalEvictorContext.java
index 5ab2577d93a..800c3bf59f3 100644
--- a/java/src/Freeze/TransactionalEvictorContext.java
+++ b/java/src/Freeze/TransactionalEvictorContext.java
@@ -169,7 +169,7 @@ class TransactionalEvictorContext implements Ice.DispatchInterceptorAsyncCallbac
{
if(!_readOnly && !_removed)
{
- EvictorI.updateStats(_rec.stats, System.currentTimeMillis());
+ EvictorI.updateStats(_rec.stats, IceInternal.Time.currentMonotonicTimeMillis());
_store.update(_current.id, _rec, _tx);
if(_trace >= 3)
diff --git a/java/src/Freeze/TransactionalEvictorI.java b/java/src/Freeze/TransactionalEvictorI.java
index 4f7dc0a9e65..932efcf5bc0 100644
--- a/java/src/Freeze/TransactionalEvictorI.java
+++ b/java/src/Freeze/TransactionalEvictorI.java
@@ -61,7 +61,7 @@ class TransactionalEvictorI extends EvictorI implements TransactionalEvictor
_deactivateController.lock();
try
{
- long currentTime = System.currentTimeMillis();
+ long currentTime = IceInternal.Time.currentMonotonicTimeMillis();
ObjectRecord rec = new ObjectRecord(servant, new Statistics(currentTime, 0, 0));
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index fd43037a4b6..e1990c041a7 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -195,7 +195,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
{
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
//
@@ -396,7 +396,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_state != StateClosed && _endpoint.timeout() >= 0)
{
long absoluteWaitTime = _stateTime + _endpoint.timeout();
- long waitTime = absoluteWaitTime - System.currentTimeMillis();
+ long waitTime = absoluteWaitTime - IceInternal.Time.currentMonotonicTimeMillis();
if(waitTime > 0)
{
@@ -405,7 +405,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
// connection.
//
wait(waitTime);
- if(System.currentTimeMillis() >= absoluteWaitTime)
+ if(IceInternal.Time.currentMonotonicTimeMillis() >= absoluteWaitTime)
{
setState(StateClosed, new CloseTimeoutException());
}
@@ -492,7 +492,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
!_batchStreamInUse && _batchStream.isEmpty() &&
_dispatchCount == 0)
{
- if(System.currentTimeMillis() >= _acmAbsoluteTimeoutMillis)
+ if(IceInternal.Time.currentMonotonicTimeMillis() >= _acmAbsoluteTimeoutMillis)
{
setState(StateClosing, new ConnectionTimeoutException());
return;
@@ -555,7 +555,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
}
@@ -703,7 +703,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
}
@@ -1022,7 +1022,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
//
@@ -1161,7 +1161,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
}
catch(IceInternal.LocalExceptionWrapper ex) // Java-specific workaround in Transceiver.write().
@@ -1515,7 +1515,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
_batchRequestCompress = false;
_dispatchCount = 0;
_state = StateNotValidated;
- _stateTime = System.currentTimeMillis();
+ _stateTime = IceInternal.Time.currentMonotonicTimeMillis();
if(_endpoint.datagram())
{
@@ -1874,7 +1874,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
}
_state = state;
- _stateTime = System.currentTimeMillis();
+ _stateTime = IceInternal.Time.currentMonotonicTimeMillis();
notifyAll();
@@ -2037,7 +2037,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000;
+ _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000;
}
try
diff --git a/java/src/IceInternal/LocatorTable.java b/java/src/IceInternal/LocatorTable.java
index 5e3e986890f..a9dab14bfc7 100644
--- a/java/src/IceInternal/LocatorTable.java
+++ b/java/src/IceInternal/LocatorTable.java
@@ -41,7 +41,8 @@ final class LocatorTable
synchronized void
addAdapterEndpoints(String adapter, IceInternal.EndpointI[] endpoints)
{
- _adapterEndpointsTable.put(adapter, new EndpointTableEntry(System.currentTimeMillis(), endpoints));
+ _adapterEndpointsTable.put(adapter,
+ new EndpointTableEntry(IceInternal.Time.currentMonotonicTimeMillis(), endpoints));
}
synchronized IceInternal.EndpointI[]
@@ -70,7 +71,7 @@ final class LocatorTable
synchronized void
addProxy(Ice.Identity id, Ice.ObjectPrx proxy)
{
- _objectTable.put(id, new ProxyTableEntry(System.currentTimeMillis(), proxy));
+ _objectTable.put(id, new ProxyTableEntry(IceInternal.Time.currentMonotonicTimeMillis(), proxy));
}
synchronized Ice.ObjectPrx
@@ -90,7 +91,7 @@ final class LocatorTable
}
else
{
- return System.currentTimeMillis() - time <= ((long)ttl * 1000);
+ return IceInternal.Time.currentMonotonicTimeMillis() - time <= ((long)ttl * 1000);
}
}
diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java
index fa9e22315d1..8f49c69ac06 100644
--- a/java/src/IceInternal/OutgoingAsync.java
+++ b/java/src/IceInternal/OutgoingAsync.java
@@ -229,7 +229,7 @@ public abstract class OutgoingAsync
//
if(_absoluteTimeoutMillis > 0)
{
- return System.currentTimeMillis() >= _absoluteTimeoutMillis;
+ return IceInternal.Time.currentMonotonicTimeMillis() >= _absoluteTimeoutMillis;
}
else
{
@@ -347,7 +347,7 @@ public abstract class OutgoingAsync
Ice.ConnectionI con = _delegate.__getConnection(comp);
if(con.timeout() >= 0)
{
- _absoluteTimeoutMillis = System.currentTimeMillis() + con.timeout();
+ _absoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + con.timeout();
}
else
{
diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java
index 8b5693fdb3f..f07bff3a62c 100644
--- a/java/src/IceInternal/TcpTransceiver.java
+++ b/java/src/IceInternal/TcpTransceiver.java
@@ -186,9 +186,9 @@ final class TcpTransceiver implements Transceiver
{
if(timeout > 0)
{
- long start = System.currentTimeMillis();
+ long start = IceInternal.Time.currentMonotonicTimeMillis();
int n = _writeSelector.select(timeout);
- if(n == 0 && System.currentTimeMillis() >= start + timeout)
+ if(n == 0 && IceInternal.Time.currentMonotonicTimeMillis() >= start + timeout)
{
throw new Ice.TimeoutException();
}
@@ -286,9 +286,9 @@ final class TcpTransceiver implements Transceiver
{
if(timeout > 0)
{
- long start = System.currentTimeMillis();
+ long start = IceInternal.Time.currentMonotonicTimeMillis();
int n = _readSelector.select(timeout);
- if(n == 0 && System.currentTimeMillis() >= start + timeout)
+ if(n == 0 && IceInternal.Time.currentMonotonicTimeMillis() >= start + timeout)
{
throw new Ice.TimeoutException();
}