1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.archive.io.warc;
24
25 import java.util.concurrent.atomic.AtomicInteger;
26
27 import org.apache.commons.pool.BasePoolableObjectFactory;
28 import org.archive.io.WriterPool;
29 import org.archive.io.WriterPoolMember;
30 import org.archive.io.WriterPoolSettings;
31
32
33 /***
34 * A pool of WARCWriters.
35 * @author stack
36 * @version $Revision: 4566 $ $Date: 2006-08-31 09:51:41 -0700 (Thu, 31 Aug 2006) $
37 */
38 public class WARCWriterPool extends WriterPool {
39 /***
40 * Constructor
41 * @param settings Settings for this pool.
42 * @param poolMaximumActive
43 * @param poolMaximumWait
44 */
45 public WARCWriterPool(final WriterPoolSettings settings,
46 final int poolMaximumActive, final int poolMaximumWait) {
47 this(new AtomicInteger(), settings, poolMaximumActive, poolMaximumWait);
48 }
49
50 /***
51 * Constructor
52 * @param serial Used to generate unique filename sequences
53 * @param settings Settings for this pool.
54 * @param poolMaximumActive
55 * @param poolMaximumWait
56 */
57 public WARCWriterPool(final AtomicInteger serial,
58 final WriterPoolSettings settings,
59 final int poolMaximumActive, final int poolMaximumWait) {
60 super(serial, new BasePoolableObjectFactory() {
61 public Object makeObject() throws Exception {
62 return new WARCWriter(serial,
63 settings.getOutputDirs(),
64 settings.getPrefix(), settings.getSuffix(),
65 settings.isCompressed(), settings.getMaxSize(),
66 settings.getMetadata());
67 }
68
69 public void destroyObject(Object writer)
70 throws Exception {
71 ((WriterPoolMember)writer).close();
72 super.destroyObject(writer);
73 }
74 }, settings, poolMaximumActive, poolMaximumWait);
75 }
76 }