01: /* $Id: WARCWriterPool.java 4566 2006-08-31 16:51:41Z stack-sf $
02: *
03: * Created on August 1st, 2006.
04: *
05: * Copyright (C) 2006 Internet Archive.
06: *
07: * This file is part of the Heritrix web crawler (crawler.archive.org).
08: *
09: * Heritrix is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU Lesser Public License as published by
11: * the Free Software Foundation; either version 2.1 of the License, or
12: * any later version.
13: *
14: * Heritrix is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: * GNU Lesser Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser Public License
20: * along with Heritrix; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: package org.archive.io.warc.v10;
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: * A pool of WARCWriters.
34: * @author stack
35: * @version $Revision: 4566 $ $Date: 2006-08-31 09:51:41 -0700 (Thu, 31 Aug 2006) $
36: */
37: public class WARCWriterPool extends WriterPool {
38: /**
39: * Constructor
40: * @param settings Settings for this pool.
41: * @param poolMaximumActive
42: * @param poolMaximumWait
43: */
44: public WARCWriterPool(final WriterPoolSettings settings,
45: final int poolMaximumActive, final int poolMaximumWait) {
46: this (new AtomicInteger(), settings, poolMaximumActive,
47: 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 ExperimentalWARCWriter(serial, settings
63: .getOutputDirs(), settings.getPrefix(),
64: settings.getSuffix(), settings.isCompressed(),
65: settings.getMaxSize(), settings.getMetadata());
66: }
67:
68: public void destroyObject(Object writer) throws Exception {
69: ((WriterPoolMember) writer).close();
70: super.destroyObject(writer);
71: }
72: }, settings, poolMaximumActive, poolMaximumWait);
73: }
74: }
|