summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/ConnectionMonitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceInternal/ConnectionMonitor.java')
-rw-r--r--java/src/IceInternal/ConnectionMonitor.java214
1 files changed, 107 insertions, 107 deletions
diff --git a/java/src/IceInternal/ConnectionMonitor.java b/java/src/IceInternal/ConnectionMonitor.java
index 22f5c671e3f..de44f64fe71 100644
--- a/java/src/IceInternal/ConnectionMonitor.java
+++ b/java/src/IceInternal/ConnectionMonitor.java
@@ -18,42 +18,42 @@ public final class ConnectionMonitor extends Thread
public void
_destroy()
{
- synchronized(this)
- {
- assert(_instance != null);
-
- _instance = null;
- _connections = null;
-
- notify();
- }
-
- while(true)
- {
- try
- {
- join();
- break;
- }
- catch(java.lang.InterruptedException ex)
- {
- continue;
- }
- }
+ synchronized(this)
+ {
+ assert(_instance != null);
+
+ _instance = null;
+ _connections = null;
+
+ notify();
+ }
+
+ while(true)
+ {
+ try
+ {
+ join();
+ break;
+ }
+ catch(java.lang.InterruptedException ex)
+ {
+ continue;
+ }
+ }
}
public synchronized void
add(Ice.ConnectionI connection)
{
- assert(_instance != null);
- _connections.add(connection);
+ assert(_instance != null);
+ _connections.add(connection);
}
public synchronized void
remove(Ice.ConnectionI connection)
{
- assert(_instance != null);
- _connections.remove(connection);
+ assert(_instance != null);
+ _connections.remove(connection);
}
//
@@ -61,111 +61,111 @@ public final class ConnectionMonitor extends Thread
//
ConnectionMonitor(Instance instance, int interval)
{
- _instance = instance;
- _interval = interval;
+ _instance = instance;
+ _interval = interval;
String threadName = _instance.initializationData().properties.getProperty("Ice.ProgramName");
if(threadName.length() > 0)
{
threadName += "-";
}
- setName(threadName + "Ice.ConnectionMonitor");
+ setName(threadName + "Ice.ConnectionMonitor");
- assert(_interval > 0);
- start();
+ assert(_interval > 0);
+ start();
}
protected synchronized void
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_instance == null);
- IceUtil.Assert.FinalizerAssert(_connections == null);
-
+ IceUtil.Assert.FinalizerAssert(_instance == null);
+ IceUtil.Assert.FinalizerAssert(_connections == null);
+
super.finalize();
}
public void
run()
{
- java.util.HashSet connections = new java.util.HashSet();
+ java.util.HashSet connections = new java.util.HashSet();
- while(true)
- {
- synchronized(this)
- {
- if(_instance != null)
- {
- try
- {
- wait(_interval * 1000);
- }
- catch(InterruptedException ex)
- {
- continue;
- }
- }
+ while(true)
+ {
+ synchronized(this)
+ {
+ if(_instance != null)
+ {
+ try
+ {
+ wait(_interval * 1000);
+ }
+ catch(InterruptedException ex)
+ {
+ continue;
+ }
+ }
- if(_instance == null)
- {
- return;
- }
+ if(_instance == null)
+ {
+ return;
+ }
- connections.clear();
- connections.addAll(_connections);
- }
-
- //
- // Monitor connections outside the thread synchronization,
- // so that connections can be added or removed during
- // monitoring.
- //
- java.util.Iterator iter = connections.iterator();
- while(iter.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)iter.next();
+ connections.clear();
+ connections.addAll(_connections);
+ }
+
+ //
+ // Monitor connections outside the thread synchronization,
+ // so that connections can be added or removed during
+ // monitoring.
+ //
+ java.util.Iterator iter = connections.iterator();
+ while(iter.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)iter.next();
- try
- {
- connection.monitor();
- }
- catch(Ice.LocalException ex)
- {
- synchronized(this)
- {
- if(_instance == null)
- {
- return;
- }
+ try
+ {
+ connection.monitor();
+ }
+ catch(Ice.LocalException ex)
+ {
+ synchronized(this)
+ {
+ if(_instance == null)
+ {
+ return;
+ }
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception in connection monitor thread " + getName() + ":\n" +
- sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
- catch(java.lang.Exception ex)
- {
- synchronized(this)
- {
- if(_instance == null)
- {
- return;
- }
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "unknown exception in connection monitor thread " + getName() + ":\n" +
- sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
- }
- }
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in connection monitor thread " + getName() + ":\n" +
+ sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+ catch(java.lang.Exception ex)
+ {
+ synchronized(this)
+ {
+ if(_instance == null)
+ {
+ return;
+ }
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "unknown exception in connection monitor thread " + getName() + ":\n" +
+ sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+ }
+ }
}
private Instance _instance;