Class WARCWriter
java.lang.Object
org.archive.io.WriterPoolMember
org.archive.io.warc.WARCWriter
WARC implementation.
Assumption is that the caller is managing access to this WARCWriter ensuring only one thread accessing this WARC instance at any one time.
While being written, WARCs have a '.open' suffix appended.
- Version:
- $Revision: 4604 $ $Date: 2006-09-05 22:38:18 -0700 (Tue, 05 Sep 2006) $
- Author:
- stack
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic byte[]NEWLINE as bytes.static final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.archive.io.WriterPoolMember
countOut, currentBasename, currentTimestamp, DEFAULT_PREFIX, DEFAULT_TEMPLATE, f, out, roundRobinIndex, scratchbuffer, serialNoFormatter, serialNoFormatterSymbols, settings, UTF8 -
Constructor Summary
ConstructorsConstructorDescriptionWARCWriter(AtomicInteger serialNo, OutputStream out, File f, WARCWriterPoolSettings settings) Constructor.WARCWriter(AtomicInteger serialNo, WARCWriterPoolSettings settings) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbaseCharacterCheck(char c, String parameter) protected StringcheckHeaderLineMimetypeParameter(String parameter) protected StringcheckHeaderValue(String value) protected StringcreateFile(File file) protected StringcreateRecordHeader(WARCRecordInfo metaRecord) protected URIgenerateRecordId(String key, String value) protected URIgenerateRecordId(Map<String, String> qualifiers) static longgetStat(ConcurrentMap<String, ConcurrentMap<String, AtomicLong>> map, String key, String subkey) static longvoidvoidprotected voidprotected voidtally(WARCConstants.WARCRecordType warcRecordType, long contentBytes, long totalBytes, long sizeOnDisk) voidwriteRecord(WARCRecordInfo recordInfo) writeWarcinfoRecord(String filename) writeWarcinfoRecord(String filename, String description) Methods inherited from class org.archive.io.WriterPoolMember
checkSize, checkWriteable, close, copyFrom, createFile, flush, generateNewBasename, getBaseFilename, getFile, getNextDirectory, getOutputStream, getPosition, isCompressed, isOversize, postWriteRecordTasks, preWriteRecordTasks, write, write, write
-
Field Details
-
TOTALS
- See Also:
-
SIZE_ON_DISK
- See Also:
-
TOTAL_BYTES
- See Also:
-
CONTENT_BYTES
- See Also:
-
NUM_RECORDS
- See Also:
-
CRLF_BYTES
public static byte[] CRLF_BYTESNEWLINE as bytes.
-
-
Constructor Details
-
WARCWriter
public WARCWriter(AtomicInteger serialNo, OutputStream out, File f, WARCWriterPoolSettings settings) throws IOException Constructor. Takes a stream. Use with caution. There is no upperbound check on size. Will just keep writing. Only pass Streams that are bounded.- Parameters:
serialNo- used to generate unique file name sequencesout- Where to write.f- File theoutis connected to.- Throws:
IOException
-
WARCWriter
Constructor.
-
-
Method Details
-
createFile
- Overrides:
createFilein classWriterPoolMember- Throws:
IOException
-
baseCharacterCheck
- Throws:
IllegalArgumentException
-
checkHeaderValue
- Throws:
IllegalArgumentException
-
checkHeaderLineMimetypeParameter
- Throws:
IllegalArgumentException
-
createRecordHeader
- Throws:
IllegalArgumentException
-
writeRecord
- Throws:
IOException
-
getFilenameWithoutOccupiedSuffix
-
tally
protected void tally(WARCConstants.WARCRecordType warcRecordType, long contentBytes, long totalBytes, long sizeOnDisk) -
subtally
-
generateRecordId
- Throws:
IOException
-
generateRecordId
- Throws:
IOException
-
writeWarcinfoRecord
- Throws:
IOException
-
writeWarcinfoRecord
- Throws:
IOException
-
resetTmpStats
public void resetTmpStats()- See Also:
-
getTmpStats
-
getStat
-
getStat
public static long getStat(ConcurrentMap<String, ConcurrentMap<String, AtomicLong>> map, String key, String subkey) -
resetTmpRecordLog
public void resetTmpRecordLog() -
getTmpRecordLog
-