|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object janus.net.ConnectionPool
public class ConnectionPool
Diese Klasse stellt einen Pool von Connection-Objekten zur Verfügung
Nested Class Summary | |
---|---|
class |
ConnectionPool.PoolElement
innere Klasse für Connections |
Field Summary | |
---|---|
protected int |
currentSize
Aktuelle Größe des Pools |
protected boolean |
debug
Debugging-Flag |
protected PrintWriter |
debugStream
PrintWriter für Debugging |
protected static PrintWriter |
debugStreamStatic
PrintWriter für Debugging (static) |
static int |
DEFAULT_TIMEOUT
Standardwert für den Timeout bei getConnection(int) |
protected Vector |
elements
Vektor mit aktiven Pool-Elementen |
protected String |
host
TCP/IP-Adresse des Hosts |
protected Thread |
idleThread
Der Idle-Thread |
protected long |
idleTime
Idle-Zeit in Milli-Sekunden |
protected int |
index
Index der nächsten zu vergebenden Verbindung |
protected String |
name
Name des Pools |
protected String |
pathmon
Initialisierungs-Information (Pathmon-Name) |
protected static Hashtable |
poolTable
Verwaltung mehrerer Pools mit Namen |
protected int |
port
TCP/IP-Port des Hosts (letzter benutzer Port) |
protected int |
port1
TCP/IP-Port des Hosts (Anfang des Bereichs) |
protected int |
port2
TCP/IP-Port des Hosts (Ende des Bereichs) |
protected int |
size
Maximale Größe des Pools |
protected int |
timeout
Default-Timeout |
Constructor Summary | |
---|---|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
boolean debug)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
boolean compress,
boolean debug)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
boolean compress,
PrintWriter stream)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
boolean compress,
String file)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
PrintWriter stream)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(int size,
String host,
int port1,
int port2,
String pathmon,
String file)
Konstruktor - erzeugt einen Pool |
|
ConnectionPool(String name,
int size,
String host,
int port1,
int port2,
String pathmon,
boolean debug)
Konstruktor - erzeugt einen benamten Pool |
|
ConnectionPool(String name,
int size,
String host,
int port1,
int port2,
String pathmon,
PrintWriter stream)
Konstruktor - erzeugt einen benamten Pool |
|
ConnectionPool(String name,
int size,
String host,
int port1,
int port2,
String pathmon,
String file)
Konstruktor - erzeugt einen benamten Pool |
Method Summary | |
---|---|
protected ConnectionPool.PoolElement |
addElement()
Erzeuge ein neues Element mit neuer Verbindung |
static void |
clearConfig()
Lösche die alte Konfiguration |
static void |
configure(Properties props)
Konfiguriere die Pools. |
protected Connection |
createConnection()
Erzeuge eine neue Connection |
void |
deleteConnection(Connection conn)
Lösche eine Connection aus dem Pool |
void |
finalize()
Finalizer - trennt alle Verbindungen |
protected static boolean |
getBoolProperty(Properties props,
String poolname,
String property,
boolean defvalue)
Hilfsfunktion zum Lesen einer Boolean-Property |
Connection |
getConnection()
Factory für Verbindungen. |
Connection |
getConnection(int timeout)
Factory für Verbindungen |
static ConnectionPool |
getConnectionPool(String name)
Ermittle einen Pool anhand seines Namens |
int |
getCurrentSize()
Rückgabe der aktuellen Größe |
PrintWriter |
getDebugStream()
Rückgabe des DebugStream |
ConnectionPool.PoolElement |
getElement(Connection connection)
Zugriff auf den Elemente-Vector |
ConnectionPool.PoolElement |
getElement(int i)
Zugriff auf den Elemente-Vector nach Index |
Enumeration |
getElements()
Rückgabe des Elementvektors als Enumeration |
String |
getHost()
Rückgabe des Hostnamens |
int |
getIdleTime()
Rückgabe der Idle-Zeit |
int |
getIndex()
Rückgabe der nächsten verwendeten Connection |
protected static int |
getIntProperty(Properties props,
String poolname,
String property,
int defvalue)
Hilfsfunktion zum Lesen einer Integer-Property |
String |
getName()
Rückgabe des Namens |
String |
getPathmon()
Rückgabe des Pathmon-Namens |
static ConnectionPool |
getPool(String pool)
Gebe einen benamten Pool zurück |
static Hashtable |
getPools()
Gebe alle Pools zurück |
int |
getPort()
Rückgabe des zuletzt verwendeten TCP/IP-Ports |
int |
getPort1()
Rückgabe des ersten TCP/IP-Ports |
int |
getPort2()
Rückgabe des zweiten TCP/IP-Ports |
protected static String |
getProperty(Properties props,
String poolname,
String property,
String defvalue)
Hilfsfunktion zum Lesen einer Property |
int |
getSize()
Rückgabe der Größe |
int |
getTimeout()
Rückgabe des Standard-Timeouts für getConnection(int) |
Object |
getUserObject(Connection conn)
Ermittle das UserObject zu einer Connection. |
protected void |
init(String name,
int size,
String host,
int port1,
int port2,
String pathmon,
PrintWriter stream)
Initialisierung (Konstruktor-Helper) |
boolean |
isCompressed()
Rückgabe des Kompressions-Flags |
static boolean |
isConfigured()
Teste, ob schon Pools konfiguriert wurden |
void |
releaseConnection(Connection conn)
Gebe die Connection in den Pool zurück |
void |
run()
Idle-Thread - löscht unbenutzte Verbindungen |
void |
setDebugStream(PrintWriter stream)
Setzen des debugStream und debugStatus |
void |
setDebugStream(String file)
Setzen des debugStream und debugStatus |
static void |
setDebugStreamStatic(PrintWriter stream)
Setzen des debugStream und debugStatus (Static) |
void |
setIdleTime(int seconds)
Setze die Idle-Zeit in Sekunden |
void |
setTimeout(int timeout)
Setze den Standard-Timeout für getConnection(int) |
void |
setUserObject(Connection conn,
Object obj)
Speichere ein UserObject zusammen mit einer Connection. |
String |
toString()
toString fuer Debugging |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int currentSize
protected boolean debug
protected PrintWriter debugStream
protected static PrintWriter debugStreamStatic
public static final int DEFAULT_TIMEOUT
getConnection(int)
protected Vector elements
protected String host
protected Thread idleThread
protected long idleTime
protected int index
protected String name
protected String pathmon
protected static Hashtable poolTable
protected int port
protected int port1
protected int port2
protected int size
protected int timeout
Constructor Detail |
---|
public ConnectionPool(int size, String host, int port1, int port2, String pathmon, boolean debug)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)debug
- Testinformationen auf Konsole ausgebenpublic ConnectionPool(int size, String host, int port1, int port2, String pathmon, boolean compress, boolean debug)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)compress
- Kompression einschalten (ohne Funktion)debug
- Testinformationen auf Konsole ausgebenpublic ConnectionPool(int size, String host, int port1, int port2, String pathmon, boolean compress, PrintWriter stream)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)compress
- Kompression einschalten (ohne Funktion)stream
- PrintWriter für die Debug-Ausgabenpublic ConnectionPool(int size, String host, int port1, int port2, String pathmon, boolean compress, String file)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)compress
- Kompression einschalten (ohne Funktion)file
- Testinformationen in Debug-Datei ausgebenpublic ConnectionPool(int size, String host, int port1, int port2, String pathmon, PrintWriter stream)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)stream
- PrintWriter für die Debug-Ausgabenpublic ConnectionPool(int size, String host, int port1, int port2, String pathmon, String file)
size
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)file
- Testinformationen in Debug-Datei ausgebenpublic ConnectionPool(String name, int size, String host, int port1, int port2, String pathmon, boolean debug)
name
- Name des Poolssize
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)debug
- Testinformationen auf Konsole ausgebenpublic ConnectionPool(String name, int size, String host, int port1, int port2, String pathmon, PrintWriter stream)
name
- Name des Poolssize
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)stream
- PrintWriter für die Debug-Ausgabenpublic ConnectionPool(String name, int size, String host, int port1, int port2, String pathmon, String file)
name
- Name des Poolssize
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)file
- Testinformationen in Debug-Datei ausgebenMethod Detail |
---|
protected ConnectionPool.PoolElement addElement() throws TandemException, CommException
CommException
- Allgemeiner Kommunikationsfehler
TandemException
- Tandem-Fehlerpublic static void clearConfig()
public static void configure(Properties props)
Konfiguriere die Pools.
Beispiel einer Konfigurationsdatei für einen Pool:
# # janus.properties - 1 Pool # host=tandem pathmon=$PM port=2000 debug=false poolsize=10 maxwait=500 idletime=600 timeout=30000
Der Pool bekommt den Namen "janus".
Beispiel einer Konfigurationsdatei für mehrere Pools:
# # janus.properties # # Allgemeine Informationen host=tandem pathmon=$PM port1=2000 port2=2000 debug=false # Pool Definitionen poolcount=2 poolname.1=prod poolname.2=test # Produktion prod.poolsize=10 prod.idletime=600 prod.timeout=10000 # Test test.poolsize=2 test.host=tdmdev test.pathmon=$TEST test.idletime=600 test.debug=true prod.timeout=30000
props
- Objekt mit den Konfigurationsdatenprotected Connection createConnection() throws CommException, TandemException
CommException
- Allgemeiner Kommunikationsfehler
TandemException
- Tandem-Fehlerpublic void deleteConnection(Connection conn) throws IllegalArgumentException
conn
- Connection aus dem Pool
IllegalArgumentException
- Connection wurde nicht gefundenpublic void finalize()
finalize
in class Object
protected static boolean getBoolProperty(Properties props, String poolname, String property, boolean defvalue)
props
- Das Objekt mit den Konfigurationsdatenpoolname
- Name des Pools (Prefix der Property)property
- Name der Propertydefvalue
- Default-Wert
public Connection getConnection() throws TandemException, CommException
CommException
- Allgemeiner Kommunikationsfehler
TandemException
- Tandem-Fehlerpublic Connection getConnection(int timeout) throws TandemException, CommException
timeout
- Maximale Wartezeit in Millisekunden
CommException
- Allgemeiner Kommunikationsfehler
TandemException
- Tandem-Fehlerpublic static ConnectionPool getConnectionPool(String name)
name
- - Poolname aus der Pool-Liste
public int getCurrentSize()
public PrintWriter getDebugStream()
public ConnectionPool.PoolElement getElement(Connection connection) throws IllegalArgumentException
connection
- Connection
IllegalArgumentException
public ConnectionPool.PoolElement getElement(int i)
i
- Index im Vektor
null
seinpublic Enumeration getElements()
elements
.elements()
public String getHost()
public int getIdleTime()
public int getIndex()
protected static int getIntProperty(Properties props, String poolname, String property, int defvalue)
props
- Das Objekt mit den Konfigurationsdatenpoolname
- Name des Pools (Prefix der Property)property
- Name der Propertydefvalue
- Default-Wert
public String getName()
public String getPathmon()
public static ConnectionPool getPool(String pool)
pool
- Name des Poolspublic static Hashtable getPools()
public int getPort()
public int getPort1()
public int getPort2()
protected static String getProperty(Properties props, String poolname, String property, String defvalue)
props
- Das Objekt mit den Konfigurationsdatenpoolname
- Name des Pools (Prefix der Property)property
- Name der Propertydefvalue
- Default-Wert
public int getSize()
public int getTimeout()
getConnection(int)
public Object getUserObject(Connection conn) throws IllegalArgumentException
conn
- eine zuvor aus dem Pool entnommene Connection
IllegalArgumentException
- die Connection stammt nicht
aus dem Poolprotected void init(String name, int size, String host, int port1, int port2, String pathmon, PrintWriter stream)
name
- Name des Poolssize
- Maximale Anzahl der Connectionshost
- TCP/IP-Adresse des Hostsport1
- TCP/IP-Port des Hosts (Anfang des Bereichs)port2
- TCP/IP-Port des Hosts (Ende des Bereichs)pathmon
- Initialisierungs-Information (Pathmon-Name)stream
- PrintWriter für die Debug-Ausgabenpublic boolean isCompressed()
false
- Komprimierung wird nicht mehr
unterst&uuuml;tztpublic static boolean isConfigured()
public void releaseConnection(Connection conn) throws IllegalArgumentException
conn
- Connection, die vorher aus dem Pool entnommen wurde
IllegalArgumentException
- Connection wurde nicht gefundenpublic void run()
run
in interface Runnable
public void setDebugStream(PrintWriter stream)
stream
- Ausgabestrom füer den Tracepublic void setDebugStream(String file)
file
- Dateiname füer Debugausgaben oder ein Leerstring
bzw. null
für die Standardausgabepublic static void setDebugStreamStatic(PrintWriter stream)
stream
- Ausgabestrom füer den Tracepublic void setIdleTime(int seconds)
seconds
- Zeit: 0 - Idle-Thread ausschaltenpublic void setTimeout(int timeout)
getConnection(int)
timeout
- public void setUserObject(Connection conn, Object obj) throws IllegalArgumentException
conn
- eine zuvor aus dem Pool entnommene Connectionobj
- Das zu speichernde UserObject.
IllegalArgumentException
- die Connection stammt nicht
aus dem Poolpublic String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |