private void syncableCheck() throws IOException { OutputStream out = getOutputStream(smallBufferSize); try { int bytesWritten = dataLen / 3; out.write(data, 0, bytesWritten); ((Syncable) out).hflush(); InputStream in = getInputStream(defaultBufferSize); verify(in, bytesWritten, data); in.close(); out.write(data, bytesWritten, dataLen - bytesWritten); ((Syncable) out).hsync(); in = getInputStream(defaultBufferSize); verify(in, dataLen, data); in.close(); } finally { out.close(); } }
@Override public void hflush() throws IOException { flush(); if (out instanceof Syncable) { ((Syncable)out).hflush(); } }
@Override public void hsync() throws IOException { flush(); if (out instanceof Syncable) { ((Syncable)out).hsync(); } }
@Override public void hflush() throws IOException { if (out instanceof Syncable) { ((Syncable) out).hflush(); } else { out.flush(); } }
@Override public void hsync() throws IOException { if (out instanceof Syncable) { ((Syncable) out).hsync(); } else { out.flush(); } }
protected void flush() throws IOException { if (outputStream != null) { if (fileSystemWAL.fileContext.getDefaultFileSystem() instanceof LocalFs || fileSystemWAL.fileContext.getDefaultFileSystem() instanceof RawLocalFs) { //until the stream is closed on the local FS, readers don't see any data. close(); } else { Syncable syncableOutputStream = (Syncable)outputStream; syncableOutputStream.hflush(); syncableOutputStream.hsync(); } } }