public FilterResultMessage(String identifier, String charset, String mimeType, boolean unsafeContentType, Bucket bucket) { this.identifier = identifier; this.charset = charset; this.mimeType = mimeType; this.unsafeContentType = unsafeContentType; if (unsafeContentType) { this.dataLength = -1; } else { this.dataLength = bucket.size(); this.bucket = bucket; } }
public byte[] readSegmentCheckBlock(int segNo, int checkBlockNo) throws IOException { assert (segNo >= 0 && segNo < segments.length); assert (checkBlockNo >= 0 && checkBlockNo < segments[segNo].checkBlockCount); byte[] buf = new byte[CHKBlock.DATA_LENGTH]; long offset = offsetSegmentCheckBlocks[segNo] + checkBlockNo * CHKBlock.DATA_LENGTH; raf.pread(offset, buf, 0, buf.length); return buf; }
@Override protected void freeBucket(Bucket bucket) throws IOException { bucket.free(); } }
public static Bucket[] makeBuckets(BucketFactory bf, int count, int size) throws IOException { Bucket[] ret = new Bucket[count]; for (int i = 0; i < count; i++) { ret[i] = bf.makeBucket(size); } return ret; }
/** * Lock the main RAF open to avoid the pooled fd being closed when we are * doing a major I/O operation involving many reads/writes. */ RAFLock lockRAF() throws IOException { return raf.lockOpen(); }
public long getDataSize() { if(data == null) return finishedSize; else { return data.size(); } }
public void free(){ synchronized (this) { if(isFreed) return; isFreed = true; if(data == null) return; } data.free(); }
@Override public void close() { if(!isClosed){ isClosed = true; underlyingBuffer.close(); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + raf.hashCode(); result = prime * result + (int) (realSize ^ (realSize >>> 32)); return result; }
public void writeSegmentCheckBlock(int segNo, int checkBlockNo, byte[] buf) throws IOException { assert (segNo >= 0 && segNo < segments.length); assert (checkBlockNo >= 0 && checkBlockNo < segments[segNo].checkBlockCount); assert (buf.length == CHKBlock.DATA_LENGTH); long offset = offsetSegmentCheckBlocks[segNo] + checkBlockNo * CHKBlock.DATA_LENGTH; raf.pwrite(offset, buf, 0, buf.length); }
@Override public void innerResume(ClientContext context) throws ResumeFailedException { if(data != null) data.onResume(context); }
@Override public void onResume(ClientContext context) throws ResumeFailedException { this.factory = context.persistentBucketFactory; underlying.onResume(context); }
@Override public void onResume(ClientContext context) throws ResumeFailedException { this.factory = context.persistentBucketFactory; bucket.onResume(context); }
/** * Return the length of the data. */ long dataSize() { return bucket.size(); }
/** * Lock the originalData RAF open to avoid the pooled fd being closed when * we are doing a major I/O operation involving many reads/writes. * * @throws IOException */ RAFLock lockUnderlying() throws IOException { return originalData.lockOpen(); }
@Override public long size() { long size = underlying.size(); if(size == 0) return 0; return size - type.headerLen; }
public void freeData() { if(data != null) { data.free(); } }
@Override public void onResume(ClientContext context) throws ResumeFailedException { this.factory = context.persistentBucketFactory; bucket.onResume(context); }
public AllDataMessage(Bucket bucket, String identifier, boolean global, long startupTime, long completionTime, String mimeType) { this.bucket = bucket; this.dataLength = bucket.size(); this.identifier = identifier; this.global = global; this.startupTime = startupTime; this.completionTime = completionTime; this.mimeType = mimeType; }