jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 3865 cc2ca3d07bbb
child 8167 7599e778785f
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
     2
 * Copyright (c) 1996, 2008, 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: 3865
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: 3865
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: 3865
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
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 sun.net.www.http;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.net.ProgressSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.net.www.MeteredStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A stream that has the property of being able to be kept alive for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * multiple downloads from the same server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @author Stephen R. Pietrowicz (NCSA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author Dave Brown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
class KeepAliveStream extends MeteredStream implements Hurryable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    // instance variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    HttpClient hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    boolean hurried;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // has this KeepAliveStream been put on the queue for asynchronous cleanup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    protected boolean queuedForCleanup = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
    50
    private static final KeepAliveStreamCleaner queue = new KeepAliveStreamCleaner();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
    51
    private static Thread cleanerThread; // null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public KeepAliveStream(InputStream is, ProgressSource pi, long expected, HttpClient hc)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        super(is, pi, expected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        this.hc = hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Attempt to cache this connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public void close() throws IOException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        // If the inputstream is closed already, just return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (closed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        // If this stream has already been queued for cleanup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        if (queuedForCleanup) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        // Skip past the data that's left in the Inputstream because
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        // some sort of error may have occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // Do this ONLY if the skip won't block. The stream may have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        // been closed at the beginning of a big file and we don't want
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        // to hang around for nothing. So if we can't skip without blocking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        // we just close the socket and, therefore, terminate the keepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        // NOTE: Don't close super class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            if (expected > count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                long nskip = (long) (expected - count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                if (nskip <= available()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                    long n = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                    while (n < nskip) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                        nskip = nskip - n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                        n = skip(nskip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                } else if (expected <= KeepAliveStreamCleaner.MAX_DATA_REMAINING && !hurried) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                    //put this KeepAliveStream on the queue so that the data remaining
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                    //on the socket can be cleanup asyncronously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                    queueForCleanup(new KeepAliveCleanerEntry(this, hc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                    hc.closeServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            if (!closed && !hurried && !queuedForCleanup) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                hc.finished();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            if (pi != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                pi.finishTracking();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            if (!queuedForCleanup) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                // nulling out the underlying inputstream as well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                // httpClient to let gc collect the memories faster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                in = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                hc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                closed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /* we explicitly do not support mark/reset */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public boolean markSupported()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public void mark(int limit) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public void reset() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        throw new IOException("mark/reset not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public synchronized boolean hurry() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            /* CASE 0: we're actually already done */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            if (closed || count >= expected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            } else if (in.available() < (expected - count)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                /* CASE I: can't meet the demand */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                /* CASE II: fill our internal buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                 * Remind: possibly check memory here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                int size = (int) (expected - count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                byte[] buf = new byte[size];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                DataInputStream dis = new DataInputStream(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                dis.readFully(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                in = new ByteArrayInputStream(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                hurried = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            // e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   154
    private static void queueForCleanup(KeepAliveCleanerEntry kace) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   155
        synchronized(queue) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   156
            if(!kace.getQueuedForCleanup()) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   157
                if (!queue.offer(kace)) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   158
                    kace.getHttpClient().closeServer();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   159
                    return;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   160
                }
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   161
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   162
                kace.setQueuedForCleanup();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   163
                queue.notifyAll();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   164
            }
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   165
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   166
            boolean startCleanupThread = (cleanerThread == null);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   167
            if (!startCleanupThread) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   168
                if (!cleanerThread.isAlive()) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   169
                    startCleanupThread = true;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   170
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   173
            if (startCleanupThread) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   174
                java.security.AccessController.doPrivileged(
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   175
                    new java.security.PrivilegedAction<Void>() {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   176
                    public Void run() {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   177
                        // We want to create the Keep-Alive-SocketCleaner in the
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   178
                        // system threadgroup
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   179
                        ThreadGroup grp = Thread.currentThread().getThreadGroup();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   180
                        ThreadGroup parent = null;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   181
                        while ((parent = grp.getParent()) != null) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   182
                            grp = parent;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   183
                        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   185
                        cleanerThread = new Thread(grp, queue, "Keep-Alive-SocketCleaner");
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   186
                        cleanerThread.setDaemon(true);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   187
                        cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   188
                        cleanerThread.start();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   189
                        return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    }
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   191
                });
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   192
            }
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   193
        } // queue
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    protected long remainingToRead() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        return expected - count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    protected void setClosed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        in = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        hc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        closed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
class KeepAliveCleanerEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    KeepAliveStream kas;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    HttpClient hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public KeepAliveCleanerEntry(KeepAliveStream kas, HttpClient hc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        this.kas = kas;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        this.hc = hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    protected KeepAliveStream getKeepAliveStream() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return kas;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    protected HttpClient getHttpClient() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    protected void setQueuedForCleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        kas.queuedForCleanup = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    protected boolean getQueuedForCleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return kas.queuedForCleanup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}