|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.archive.io.WriterPoolMember
public abstract class WriterPoolMember
Member of WriterPool
.
Implements rotating off files, file naming with some guarantee of
uniqueness, and position in file. Subclass to pick up functionality for a
particular Writer type.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_PREFIX
Default file prefix. |
static java.lang.String |
DEFAULT_SUFFIX
Default for file suffix. |
static java.lang.String |
HOSTNAME_ADMINPORT_VARIABLE
Value to interpolate with actual hostname-port. |
static java.lang.String |
HOSTNAME_VARIABLE
Value to interpolate with actual hostname. |
static java.lang.String |
UTF8
|
Fields inherited from interface org.archive.io.ArchiveFileConstants |
---|
ABSOLUTE_OFFSET_KEY, CDX, CDX_FILE, CDX_LINE_BUFFER_SIZE, COMPRESSED_FILE_EXTENSION, CRLF, DATE_FIELD_KEY, DEFAULT_DIGEST_METHOD, DOT_COMPRESSED_FILE_EXTENSION, DUMP, GZIP_DUMP, HEADER, INVALID_SUFFIX, LENGTH_FIELD_KEY, MIMETYPE_FIELD_KEY, NOHEAD, OCCUPIED_SUFFIX, READER_IDENTIFIER_FIELD_KEY, RECORD_IDENTIFIER_FIELD_KEY, SINGLE_SPACE, TYPE_FIELD_KEY, URL_FIELD_KEY, VERSION_FIELD_KEY |
Constructor Summary | |
---|---|
|
WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo,
java.util.List<java.io.File> dirs,
java.lang.String prefix,
boolean cmprs,
long maxSize,
java.lang.String extension)
Constructor. |
|
WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo,
java.util.List<java.io.File> dirs,
java.lang.String prefix,
java.lang.String suffix,
boolean cmprs,
long maxSize,
java.lang.String extension)
Constructor. |
protected |
WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo,
java.io.OutputStream out,
java.io.File file,
boolean cmprs,
java.lang.String a14DigitDate)
Constructor. |
Method Summary | |
---|---|
void |
checkSize()
Call this method just before/after any significant write. |
protected java.io.File |
checkWriteable(java.io.File d)
|
void |
close()
|
protected long |
copyFrom(java.io.InputStream is,
long recordLength,
boolean enforceLength)
Copy bytes from the provided InputStream to the target file/stream being written. |
protected java.lang.String |
createFile()
Create a new file. |
protected java.lang.String |
createFile(java.io.File file)
|
protected void |
flush()
|
protected java.lang.String |
getBaseFilename()
Get the file name |
protected java.lang.String |
getCreateTimestamp()
|
java.io.File |
getFile()
Get this file. |
protected java.io.File |
getNextDirectory(java.util.List<java.io.File> dirs)
|
protected java.io.OutputStream |
getOutputStream()
|
long |
getPosition()
Postion in current physical file. |
protected TimestampSerialno |
getTimestampSerialNo()
|
protected TimestampSerialno |
getTimestampSerialNo(java.lang.String timestamp)
Do static synchronization around getting of counter and timestamp so no chance of a thread getting in between the getting of timestamp and allocation of serial number throwing the two out of alignment. |
boolean |
isCompressed()
|
protected void |
postWriteRecordTasks()
Post file write tasks. |
protected void |
preWriteRecordTasks()
Post write tasks. |
protected void |
readFullyFrom(java.io.InputStream is,
long recordLength,
byte[] b)
Deprecated. Use copyFrom(InputStream,long,boolean) instead |
protected void |
readToLimitFrom(java.io.InputStream is,
long limit,
byte[] b)
Deprecated. Use copyFrom(InputStream,long,boolean) instead |
protected int |
write(byte[] b)
|
protected int |
write(byte[] b,
int off,
int len)
|
protected int |
write(int b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UTF8
public static final java.lang.String DEFAULT_PREFIX
public static final java.lang.String HOSTNAME_VARIABLE
public static final java.lang.String HOSTNAME_ADMINPORT_VARIABLE
public static final java.lang.String DEFAULT_SUFFIX
Constructor Detail |
---|
protected WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo, java.io.OutputStream out, java.io.File file, boolean cmprs, java.lang.String a14DigitDate) throws java.io.IOException
serialNo
- used to create unique filename sequencesout
- Where to write.file
- File the out
is connected to.cmprs
- Compress the content written.a14DigitDate
- If null, we'll write current time.
java.io.IOException
public WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo, java.util.List<java.io.File> dirs, java.lang.String prefix, boolean cmprs, long maxSize, java.lang.String extension)
serialNo
- used to create unique filename sequencesdirs
- Where to drop files.prefix
- File prefix to use.cmprs
- Compress the records written.maxSize
- Maximum size for ARC files written.extension
- Extension to give file.public WriterPoolMember(java.util.concurrent.atomic.AtomicInteger serialNo, java.util.List<java.io.File> dirs, java.lang.String prefix, java.lang.String suffix, boolean cmprs, long maxSize, java.lang.String extension)
serialNo
- used to create unique filename sequencesdirs
- Where to drop files.prefix
- File prefix to use.cmprs
- Compress the records written.maxSize
- Maximum size for ARC files written.suffix
- File tail to use. If null, unused.extension
- Extension to give file.Method Detail |
---|
public void checkSize() throws java.io.IOException
Creates and opens a file if none already open. One use of this method
then is after construction, call this method to add the metadata, then
call getPosition()
to find offset of first record.
java.io.IOException
protected java.lang.String createFile() throws java.io.IOException
checkSize()
.
java.io.IOException
protected java.lang.String createFile(java.io.File file) throws java.io.IOException
java.io.IOException
protected java.io.File getNextDirectory(java.util.List<java.io.File> dirs) throws java.io.IOException
dirs
- List of File objects that point at directories.
java.io.IOException
protected java.io.File checkWriteable(java.io.File d)
protected TimestampSerialno getTimestampSerialNo()
protected TimestampSerialno getTimestampSerialNo(java.lang.String timestamp)
timestamp
- If non-null, use passed timestamp (must be 14 digit
ARC format), else if null, timestamp with now.
protected java.lang.String getBaseFilename()
public java.io.File getFile()
WriterPool
wants
to invalidate a file.
protected void preWriteRecordTasks() throws java.io.IOException
java.io.IOException
protected void postWriteRecordTasks() throws java.io.IOException
java.io.IOException
public long getPosition() throws java.io.IOException
java.io.IOException
public boolean isCompressed()
protected int write(byte[] b) throws java.io.IOException
b.length
java.io.IOException
protected void flush() throws java.io.IOException
java.io.IOException
protected int write(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
protected int write(int b) throws java.io.IOException
java.io.IOException
protected void readFullyFrom(java.io.InputStream is, long recordLength, byte[] b) throws java.io.IOException
copyFrom(InputStream,long,boolean)
instead
java.io.IOException
protected void readToLimitFrom(java.io.InputStream is, long limit, byte[] b) throws java.io.IOException
copyFrom(InputStream,long,boolean)
instead
java.io.IOException
protected long copyFrom(java.io.InputStream is, long recordLength, boolean enforceLength) throws java.io.IOException
is
- InputStream to copy bytes fromrecordLength
- expected number of bytes to copyenforceLength
- whether to throw an exception if too many/too few bytes are
available from stream
enforceLength
)
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
protected java.io.OutputStream getOutputStream()
protected java.lang.String getCreateTimestamp()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |