private byte[] encodeGeneralProgress() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { OutputStream ccos = checksumChecker.checksumWriterWithLength(baos, new ArrayBucketFactory()); DataOutputStream dos = new DataOutputStream(ccos); long flags = 0; if(hasCheckedDatastore) flags |= HAS_CHECKED_DATASTORE_FLAG; dos.writeLong(flags); errors.writeFixedLengthTo(dos); dos.close(); } catch (IOException e) { throw new Error(e); } byte[] ret = baos.toByteArray(); return ret; }
/** Encode the offsets. */ private byte[] encodeOffsets() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { OutputStream os = checker.checksumWriterWithLength(baos, new ArrayBucketFactory()); DataOutputStream dos = new DataOutputStream(os); if(this.hasPaddedLastBlock) dos.writeLong(offsetPaddedLastBlock); dos.writeLong(offsetOverallStatus); dos.writeInt(overallStatusLength); if(crossSegments != null) { for(long l : offsetCrossSegmentBlocks) dos.writeLong(l); } for(long l : offsetSegmentCheckBlocks) dos.writeLong(l); for(long l : offsetSegmentStatus) dos.writeLong(l); if(crossSegments != null) { for(long l : offsetCrossSegmentStatus) dos.writeLong(l); } for(long l : offsetSegmentKeys) dos.writeLong(l); dos.close(); return baos.toByteArray(); } catch (IOException e) { throw new Error(e); // Impossible } }
private void writeChecksummedObject(ObjectOutputStream os, Object req, String name) throws IOException { PrependLengthOutputStream oos = checker.checksumWriterWithLength(os, tempBucketFactory); try { ObjectOutputStream innerOOS = new ObjectOutputStream(oos); innerOOS.writeObject(req); innerOOS.close(); oos = null; } catch (Throwable e) { Logger.error(this, "Unable to write recovery data for "+name+" : "+e, e); oos.abort(); } finally { if(oos != null) oos.close(); } }
private void writeRecoveryData(ObjectOutputStream os, ClientRequest req) throws IOException { PrependLengthOutputStream oos = checker.checksumWriterWithLength(os, tempBucketFactory); DataOutputStream dos = new DataOutputStream(oos); try { req.getClientDetail(dos, checker); dos.close(); oos = null; } catch (Throwable e) { Logger.error(this, "Unable to write recovery data for "+req+" : "+e, e); System.err.println("Unable to write recovery data for "+req+" : "+e); e.printStackTrace(); oos.abort(); } finally { if(oos != null) oos.close(); } }
private Bucket encodeSegmentSettings() { ArrayBucket bucket = new ArrayBucket(); // Will be small. try { OutputStream os = bucket.getOutputStream(); OutputStream cos = checker.checksumWriterWithLength(os, new ArrayBucketFactory()); DataOutputStream dos = new DataOutputStream(cos); for (SplitFileInserterSegmentStorage segment : segments) { segment.writeFixedSettings(dos); } dos.close(); os.close(); return bucket; } catch (IOException e) { throw new Error(e); // Impossible } }
private byte[] encodeOverallStatus() { ArrayBucket bucket = new ArrayBucket(); // Will be small. try { OutputStream os = bucket.getOutputStream(); OutputStream cos = checker.checksumWriterWithLength(os, new ArrayBucketFactory()); DataOutputStream dos = new DataOutputStream(cos); synchronized(this) { errors.writeFixedLengthTo(dos); overallStatusDirty = false; } dos.close(); os.close(); return bucket.toByteArray(); } catch (IOException e) { throw new Error(e); // Impossible } }
dos.writeLong(MAGIC); dos.writeInt(checker.getChecksumTypeID()); OutputStream os = checker.checksumWriterWithLength(baos, new ArrayBucketFactory()); dos = new DataOutputStream(os); dos.writeInt(VERSION);
/** * This one could actually be rather large, since it includes the listing of * which blocks go in which cross-segments ... */ private Bucket encodeCrossSegmentSettings(BucketFactory bf) throws IOException { if (crossSegments == null) return new NullBucket(); Bucket bucket = bf.makeBucket(-1); OutputStream os = bucket.getOutputStream(); OutputStream cos = checker.checksumWriterWithLength(os, new ArrayBucketFactory()); DataOutputStream dos = new DataOutputStream(cos); for (SplitFileInserterCrossSegmentStorage segment : crossSegments) { segment.writeFixedSettings(dos); } dos.close(); os.close(); return bucket; }
new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory())); try { fctx.writeTo(innerDOS); if(returnType == ReturnType.DIRECT) { innerDOS = new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory())); try { returnBucketDirect.storeTo(innerDOS); new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory())); try { getFailedMessage.writeTo(innerDOS); new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory())); try { if(getter.writeTrivialProgress(innerDOS)) {