Commit b17e7496 authored by afreyssin's avatar afreyssin

Fix a memory leak (JORAM-20): no longer create a new logging topic for each daemon.

parent d3fe42b7
/*
* Copyright (C) 2002 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2002 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -24,7 +24,6 @@ package fr.dyade.aaa.common;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
/**
* The Daemon class represents a basic active component in a server. It
* provides useful code to start and safely stop inner Thread.
......@@ -121,8 +120,11 @@ public abstract class Daemon implements Runnable {
/**
* Allocates a new Daemon object.
* Be careful, the use of this constructor is not recommended as it does not
* dissociate the corresponding logger.
*
* @param name the name of the new Daemon
* @deprecated
*/
protected Daemon(String name) {
this(name, null);
......@@ -139,7 +141,7 @@ public abstract class Daemon implements Runnable {
if (logmon == null) {
// Get a default logging monitor from MonologMonitorFactory
this.logmon = Debug.getLogger(getClass().getName() + '.' + name);
this.logmon = Debug.getLogger(getClass().getName());
this.logmon.log(BasicLevel.DEBUG, getName() + ", created.");
} else {
this.logmon = logmon;
......@@ -149,7 +151,7 @@ public abstract class Daemon implements Runnable {
canStop = false;
thread = null;
}
/**
* Marks the daemon's thread as either a daemon thread a user thread.
* This method must be called before the daemon is started.
......
......@@ -31,6 +31,8 @@ import org.objectweb.util.monolog.api.Logger;
import fr.dyade.aaa.agent.conf.A3CML;
import fr.dyade.aaa.agent.conf.A3CMLConfig;
import fr.dyade.aaa.common.Daemon;
import fr.dyade.aaa.common.Debug;
import fr.dyade.aaa.util.Transaction;
/**
* A <code>AdminProxy</code> service provides a TCP service allowing remote
......@@ -63,7 +65,7 @@ public class AdminProxy {
AdminMonitor monitors[] = null;
ServerSocket listen = null;
static Logger xlogmon = null;
static Logger xlogmon = Debug.getLogger(AdminProxy.class.getName());;
/**
* Initializes the package as a well known service.
......@@ -90,24 +92,17 @@ public class AdminProxy {
nbm = 1;
}
// Get the logging monitor from current server MonologMonitorFactory
xlogmon = Debug.getLogger(Debug.A3Service + ".AdminProxy" +
".#" + AgentServer.getServerId());
if (proxy != null) {
xlogmon.log(BasicLevel.ERROR,
"AdminProxy#" + AgentServer.getServerId() +
": already initialized.");
throw new Exception("AdminProxy" + ".#" + AgentServer.getServerId() +
": already initialized.");
"AdminProxy#" + AgentServer.getServerId() + ": already initialized.");
throw new Exception("AdminProxy" + ".#" + AgentServer.getServerId() + ": already initialized.");
}
try {
proxy = new AdminProxy();
} catch (IOException exc) {
xlogmon.log(BasicLevel.ERROR,
"AdminProxy#" + AgentServer.getServerId() +
", can't get listen port", exc);
"AdminProxy#" + AgentServer.getServerId() + ", can't get listen port", exc);
throw exc;
}
start();
......@@ -136,8 +131,7 @@ public class AdminProxy {
monitors = new AdminMonitor[nbm];
for (int i=0; i<monitors.length; i++) {
monitors[i] = new AdminMonitor("AdminProxy#" +
AgentServer.getServerId() + '.' + i);
monitors[i] = new AdminMonitor("AdminProxy#" + AgentServer.getServerId() + '.' + i, xlogmon);
}
}
......@@ -214,9 +208,8 @@ public class AdminProxy {
/**
* Constructor.
*/
protected AdminMonitor(String name) {
// Get the logging monitor from AdminProxy (overload Daemon setup)
super(name, AdminProxy.xlogmon);
protected AdminMonitor(String name, Logger logger) {
super(name, logger);
this.setThreadGroup(AgentServer.getThreadGroup());
}
......@@ -341,7 +334,7 @@ public class AdminProxy {
try {
// finds variable
Class varClass = Class.forName(varClassName);
Class<?> varClass = Class.forName(varClassName);
Field var = varClass.getDeclaredField(varName);
// sets variable according to its type
String varType = var.getType().getName();
......@@ -386,7 +379,7 @@ public class AdminProxy {
try {
// finds variable
Class varClass = Class.forName(varClassName);
Class<?> varClass = Class.forName(varClassName);
Field var = varClass.getDeclaredField(varName);
// get the variable value
Object value = var.get(null);
......
/*
* Copyright (C) 2003 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -488,7 +488,7 @@ public class HttpNetwork extends StreamNetwork implements HttpNetworkMBean {
NetworkOutputStream nos = null;
NetServerOut(String name, Logger logmon) throws IOException {
super(name + ".NetServerOut");
super(name + ".NetServerOut", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
......@@ -700,7 +700,7 @@ public class HttpNetwork extends StreamNetwork implements HttpNetworkMBean {
NetworkOutputStream nos = null;
NetServerIn(String name, ServerSocket listen, Logger logmon) throws IOException {
super(name + ".NetServerIn");
super(name + ".NetServerIn", logmon);
this.listen = listen;
// Overload logmon definition in Daemon
this.logmon = logmon;
......
/*
* Copyright (C) 2003 - 2005 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -244,7 +244,7 @@ public class NGNetwork extends StreamNetwork {
final class Dispatcher extends Daemon {
Dispatcher(String name, Logger logmon) {
super(name + ".dispatcher");
super(name + ".dispatcher", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
}
......@@ -288,7 +288,7 @@ public class NGNetwork extends StreamNetwork {
final class NetServer extends Daemon {
NetServer(String name, Logger logmon) throws IOException {
super(name + ".NetServer");
super(name + ".NetServer", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
......
/*
* Copyright (C) 2004 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2008 CSSI
*
* This library is free software; you can redistribute it and/or
......@@ -620,7 +620,7 @@ public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean {
ServerSocket listen = null;
WakeOnConnection(String name, Logger logmon) throws IOException {
super(name + ".wakeOnConnection");
super(name + ".wakeOnConnection", logmon);
// Create the listen socket in order to verify the port availability.
listen = createServerSocket();
// Overload logmon definition in Daemon
......@@ -696,7 +696,7 @@ public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean {
final class Dispatcher extends Daemon {
Dispatcher(String name, Logger logmon) {
super(name + ".dispatcher");
super(name + ".dispatcher", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
}
......@@ -783,7 +783,7 @@ public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean {
private Object lock;
WatchDog(String name, Logger logmon) {
super(name + ".watchdog");
super(name + ".watchdog", logmon);
lock = new Object();
// Overload logmon definition in Daemon
this.logmon = logmon;
......@@ -851,7 +851,7 @@ public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean {
NetSession session = null;
Sender(NetSession session, String name, Logger logmon) {
super(name + ".sender");
super(name + ".sender", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
this.session = session;
......
/*
* Copyright (C) 2003 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 - France Telecom R&D
*
* This library is free software; you can redistribute it and/or
......@@ -168,7 +168,7 @@ public class SimpleNetwork extends StreamNetwork {
NetworkOutputStream nos = null;
NetServerOut(String name, Logger logmon) {
super(name + ".NetServerOut");
super(name + ".NetServerOut", logmon);
// Overload logmon definition in Daemon
this.logmon = logmon;
this.setThreadGroup(AgentServer.getThreadGroup());
......@@ -396,7 +396,7 @@ public class SimpleNetwork extends StreamNetwork {
ServerSocket listen = null;
NetServerIn(String name, Logger logmon) throws IOException {
super(name + ".NetServerIn");
super(name + ".NetServerIn", logmon);
// Create the listen socket in order to verify the port availability.
listen = createServerSocket();
// Overload logmon definition in Daemon
......
/*
* Copyright (C) 2008 ScalAgent Distributed Technologies
* Copyright (C) 2008 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -859,7 +859,7 @@ public class UDPNetwork extends Network implements UDPNetworkMBean {
private boolean force = false;
WatchDog(String name, Logger logmon) {
super(name + ".watchdog");
super(name + ".watchdog", logmon);
lock = new Object();
// Overload logmon definition in Daemon
this.logmon = logmon;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -88,7 +88,7 @@ public class HATcpServer {
protected Monitor(String name,
HATcpServer tcpServer) {
super(name);
super(name, Trace.logger);
this.tcpServer = tcpServer;
}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2011 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -91,7 +91,7 @@ public class TcpServer {
boolean stopping = false;
protected Monitor(String name, int timeout, TcpServer tcpServer) {
super(name);
super(name, Trace.logger);
this.timeout = timeout;
this.tcpServer = tcpServer;
}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -47,8 +47,7 @@ import fr.dyade.aaa.common.Queue;
public class MultiSessionConsumer extends MessageConsumerListener
implements javax.jms.ConnectionConsumer{
private static final Logger logger =
Debug.getLogger(MultiSessionConsumer.class.getName());
private static final Logger logger = Debug.getLogger(MultiSessionConsumer.class.getName());
private ServerSessionPool sessPool;
......@@ -179,7 +178,7 @@ public class MultiSessionConsumer extends MessageConsumerListener
class MessageDispatcher extends Daemon {
MessageDispatcher(String name) {
super(name);
super(name, logger);
}
/* (non-Javadoc)
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -2180,7 +2180,7 @@ public class Session implements javax.jms.Session {
*/
private class SessionDaemon extends fr.dyade.aaa.common.Daemon {
SessionDaemon() {
super("Connection#" + cnx + " - Session#" + ident);
super("Connection#" + cnx + " - Session#" + ident, logger);
}
public void run() {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2011 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -22,7 +22,6 @@
*/
package org.objectweb.joram.client.jms.connection;
import java.net.SocketException;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
......@@ -30,6 +29,9 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import javax.jms.IllegalStateException;
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
......@@ -43,8 +45,6 @@ import org.objectweb.joram.shared.client.MomExceptionReply;
import org.objectweb.joram.shared.client.PingRequest;
import org.objectweb.joram.shared.client.SessDenyRequest;
import org.objectweb.joram.shared.excepts.MomException;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import fr.dyade.aaa.common.Debug;
......@@ -437,7 +437,7 @@ public class RequestMultiplexer {
// The real name is set later when
// the proxy id and connection id are known
// see setDemultiplexerDaemonName()
super("Connection#?");
super("Connection#?", logger);
}
public void run() {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
......@@ -109,7 +109,7 @@ public class TcpConnectionListener extends Daemon {
* @param timeout the timeout
*/
public TcpConnectionListener(TcpProxyService proxyService, int timeout) {
super("TcpConnectionListener");
super("TcpConnectionListener", logger);
this.proxyService = proxyService;
this.timeout = timeout;
this.clockSynchroThreshold = Configuration.getLong(CLOCK_SYNCHRO_THRESHOLD, clockSynchroThreshold).longValue();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
......@@ -62,7 +62,7 @@ public class TcpReader extends Daemon {
AgentId proxyId,
TcpConnection tcpConnection,
boolean closeConnection) {
super("tcpReader." + tcpConnection.getKey());
super("tcpReader." + tcpConnection.getKey(), logger);
this.ioctrl = ioctrl;
this.proxyId = proxyId;
this.tcpConnection = tcpConnection;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
......@@ -56,7 +56,7 @@ public class TcpWriter extends Daemon {
public TcpWriter(IOControl ioctrl,
AckedQueue replyQueue,
TcpConnection tcpConnection) {
super("tcpWriter." + tcpConnection.getKey());
super("tcpWriter." + tcpConnection.getKey(), logger);
this.ioctrl = ioctrl;
this.replyQueue = replyQueue;
this.tcpConnection = tcpConnection;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -739,7 +739,7 @@ public class JMSBridgeModule implements javax.jms.ExceptionListener,
protected class StartupDaemon extends Daemon {
/** Constructs a <code>StartupDaemon</code> thread. */
protected StartupDaemon() {
super(agentId.toString() + ":StartupDaemon");
super(agentId.toString() + ":StartupDaemon", logger);
setDaemon(false);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "StartupDaemon<init> " + agentId);
......@@ -890,7 +890,7 @@ public class JMSBridgeModule implements javax.jms.ExceptionListener,
/** Constructs a <code>ReconnectionDaemon</code> thread. */
protected ReconnectionDaemon() {
super(agentId.toString() + ":ReconnectionDaemon");
super(agentId.toString() + ":ReconnectionDaemon", logger);
setDaemon(false);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "ReconnectionDaemon<init> " + agentId);
......@@ -982,7 +982,7 @@ public class JMSBridgeModule implements javax.jms.ExceptionListener,
/** Constructs a <code>ReceiverDaemon</code> thread. */
protected ConsumerDaemon() {
super(agentId.toString() + ":ConsumerDaemon");
super(agentId.toString() + ":ConsumerDaemon", logger);
setDaemon(false);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "ConsumerDaemon<init> " + agentId);
......@@ -1167,7 +1167,7 @@ public class JMSBridgeModule implements javax.jms.ExceptionListener,
/** Constructs a <code>XARecoverDaemon</code> thread. */
protected XARecoverDaemon(XAResource resource) {
super(agentId.toString() + ":XARecoverDaemon");
super(agentId.toString() + ":XARecoverDaemon", logger);
this.resource = resource;
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "XARecoverDaemon<init> " + agentId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment