question: private void sendResource ( final UUID uuid , final Object resource , final long length , final InputStream is ) throws IOException { assert uuid != null ; assert resource != null ; assert length >= 0 ; assert is != null ; assert ! sentStatus ; long bytesWritten = 0L ; final long begin = System . nanoTime ( ) ; final OutputStream os = s . getOutputStream ( ) ; try { { final DataOutputStream dos = new DataOutputStream ( os ) ; dos . write ( new byte [ ] { StatusEnum . OK . get ( ) } ) ; dos . writeLong ( length ) ; dos . flush ( ) ; bytesWritten += 1 + Bytes . SIZEOF_LONG ; sentStatus = true ; } final long checksum ; { final int BUFSIZE = Bytes . kilobyte32 * 2 ; final CheckedInputStream cis = new CheckedInputStream ( new BufferedInputStream ( is ) , new Adler32 ( ) ) ; final byte [ ] buff = new byte [ BUFSIZE ] ; while ( true ) { final int read = cis . read ( buff , 0 , BUFSIZE ) ; if ( read <= 0 ) break ; os . write ( buff , 0 , read ) ; bytesWritten += read ; } checksum = cis . getChecksum ( ) . getValue ( ) ; } { final DataOutputStream dos = new DataOutputStream ( os ) ; dos . writeLong ( checksum ) ; bytesWritten += Bytes . SIZEOF_LONG ; dos . flush ( ) ; } os . flush ( ) ; if ( log . isInfoEnabled ( ) ) log . info ( "Sent: uuid=" + uuid + ", resource=" + resource + ", length=" + length + ", checksum=" + checksum + ", elapsed=" + TimeUnit . NANOSECONDS . toMillis ( System . nanoTime ( ) - begin ) + "ms" ) ; } finally { try { os . close ( ) ; } catch ( Throwable t ) { } counters . bytesWritten . add ( bytesWritten ) ; counters . elapsedWriteNanos . add ( System . nanoTime ( ) - begin ) ; synchronized ( counters . maxWriteSizeLock ) { counters . maxWriteSize = Math . max ( counters . maxWriteSize , bytesWritten ) ; } } }
target:  Sends given resource to the socket.