jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java
author prappo
Fri, 01 Aug 2014 22:32:51 +0100
changeset 25808 e113d0a0fde0
parent 10324 e28265130e4f
permissions -rw-r--r--
8054158: Fix typos in JNDI-related packages Reviewed-by: rriggs, vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jndi.ldap.pool;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.WeakHashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.LinkedList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.PrintStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.lang.ref.Reference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.lang.ref.ReferenceQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * A map of pool ids to Connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Key is an object that uniquely identifies a PooledConnection request
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * (typically information needed to create the connection).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The definitions of the key's equals() and hashCode() methods are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * vital to its unique identification in a Pool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Value is a ConnectionsRef, which is a reference to Connections,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * a list of equivalent connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Supports methods that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * - retrieves (or creates as necessary) a connection from the pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * - removes expired connections from the pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Connections cleanup:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * A WeakHashMap is used for mapping the pool ids and Connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * A SoftReference from the value to the key is kept to hold the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * entry as long as possible. This allows the GC to remove Connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * from the Pool under situations of VM running out of resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * To take an appropriate action of 'closing the connections' before the GC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * reclaims the ConnectionsRef objects, the ConnectionsRef objects are made
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * weakly reachable through a list of weak references registered with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * a reference queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * Upon an entry gets removed from the WeakHashMap, the ConnectionsRef (value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * in the map) object is weakly reachable. When another sweep of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * clearing the weak references is made by the GC it puts the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * ConnectionsWeakRef object into the reference queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * The reference queue is monitored lazily for reclaimable Connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * whenever a pooled connection is requested or a call to remove the expired
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * connections is made. The monitoring is done regularly when idle connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * timeout is set as the PoolCleaner removes expired connections periodically.
25808
e113d0a0fde0 8054158: Fix typos in JNDI-related packages
prappo
parents: 10324
diff changeset
    71
 * As determined by experimentation, cleanup of resources using the
e113d0a0fde0 8054158: Fix typos in JNDI-related packages
prappo
parents: 10324
diff changeset
    72
 * ReferenceQueue mechanism is reliable and has more immediate effect than the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * finalizer approach.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
final public class Pool {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static final boolean debug = com.sun.jndi.ldap.LdapPoolManager.debug;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Used for connections cleanup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    85
    private static final ReferenceQueue<ConnectionsRef> queue =
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    86
        new ReferenceQueue<>();
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    87
    private static final Collection<Reference<ConnectionsRef>> weakRefs =
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    88
        Collections.synchronizedList(new LinkedList<Reference<ConnectionsRef>>());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    final private int maxSize;    // max num of identical conn per pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    final private int prefSize;   // preferred num of identical conn per pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    final private int initSize;   // initial number of identical conn to create
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    93
    final private Map<Object, ConnectionsRef> map;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public Pool(int initSize, int prefSize, int maxSize) {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    96
        map = new WeakHashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.prefSize = prefSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.maxSize = maxSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this.initSize = initSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Gets a pooled connection for id. The pooled connection might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * newly created, as governed by the maxSize and prefSize settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * If a pooled connection is unavailable and cannot be created due
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * to the maxSize constraint, this call blocks until the constraint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * is removed or until 'timeout' ms has elapsed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param id identity of the connection to get
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param timeout the number of milliseconds to wait before giving up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param factory the factory to use for creating the connection if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *          creation is necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @return a pooled connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @throws NamingException the connection could not be created due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *                          an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public PooledConnection getPooledConnection(Object id, long timeout,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        PooledConnectionFactory factory) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        d("get(): ", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        d("size: ", map.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        expungeStaleConnections();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        Connections conns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        synchronized (map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            conns = getConnections(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            if (conns == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                d("get(): creating new connections list for ", id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                // No connections for this id so create a new list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                conns = new Connections(id, initSize, prefSize, maxSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    factory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                ConnectionsRef connsRef = new ConnectionsRef(conns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                map.put(id, connsRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                // Create a weak reference to ConnectionsRef
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   138
                Reference<ConnectionsRef> weakRef =
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   139
                        new ConnectionsWeakRef(connsRef, queue);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                // Keep the weak reference through the element of a linked list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                weakRefs.add(weakRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        d("get(): size after: ", map.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return conns.get(timeout, factory); // get one connection from list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    private Connections getConnections(Object id) {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   152
        ConnectionsRef ref = map.get(id);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return (ref != null) ? ref.getConnections() : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Goes through the connections in this Pool and expires ones that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * have been idle before 'threshold'. An expired connection is closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * and then removed from the pool (removePooledConnection() will eventually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * be called, and the list of pools itself removed if it becomes empty).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param threshold connections idle before 'threshold' should be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *          and removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public void expire(long threshold) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        synchronized (map) {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   167
            Iterator<ConnectionsRef> iter = map.values().iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            Connections conns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            while (iter.hasNext()) {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   170
                conns = iter.next().getConnections();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                if (conns.expire(threshold)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    d("expire(): removing ", conns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        expungeStaleConnections();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Closes the connections contained in the ConnectionsRef object that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * is going to be reclaimed by the GC. Called by getPooledConnection()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * and expire() methods of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private static void expungeStaleConnections() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        ConnectionsWeakRef releaseRef = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        while ((releaseRef = (ConnectionsWeakRef) queue.poll())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                        != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            Connections conns = releaseRef.getConnections();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            if (debug) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                System.err.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        "weak reference cleanup: Closing Connections:" + conns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            // cleanup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            conns.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            weakRefs.remove(releaseRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            releaseRef.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public void showStats(PrintStream out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        Object id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        Connections conns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        out.println("===== Pool start ======================");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        out.println("maximum pool size: " + maxSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        out.println("preferred pool size: " + prefSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        out.println("initial pool size: " + initSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        out.println("current pool size: " + map.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   214
        for (Map.Entry<Object, ConnectionsRef> entry : map.entrySet()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            id = entry.getKey();
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   216
            conns = entry.getValue().getConnections();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            out.println("   " + id + ":" + conns.getStats());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        out.println("====== Pool end =====================");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        return super.toString() + " " + map.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    private void d(String msg, int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (debug) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            System.err.println(this + "." + msg + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    private void d(String msg, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (debug) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            System.err.println(this + "." + msg + obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
}