org.apache.hadoop.fs.Syncable Java Examples

The following examples show how to use org.apache.hadoop.fs.Syncable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CryptoStreamsTestBase.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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();
  }
}
 
Example #2
Source File: CryptoStreamsTestBase.java    From big-c with Apache License 2.0 6 votes vote down vote up
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();
  }
}
 
Example #3
Source File: SyncableDataOutputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void hflush() throws IOException {
  if (out instanceof Syncable) {
    ((Syncable) out).hflush();
  } else {
    out.flush();
  }
}
 
Example #4
Source File: SyncableDataOutputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void hsync() throws IOException {
  if (out instanceof Syncable) {
    ((Syncable) out).hsync();
  } else {
    out.flush();
  }
}
 
Example #5
Source File: CryptoOutputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void hflush() throws IOException {
  flush();
  if (out instanceof Syncable) {
    ((Syncable)out).hflush();
  }
}
 
Example #6
Source File: CryptoOutputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void hsync() throws IOException {
  flush();
  if (out instanceof Syncable) {
    ((Syncable)out).hsync();
  }
}
 
Example #7
Source File: SyncableDataOutputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void hflush() throws IOException {
  if (out instanceof Syncable) {
    ((Syncable) out).hflush();
  } else {
    out.flush();
  }
}
 
Example #8
Source File: SyncableDataOutputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void hsync() throws IOException {
  if (out instanceof Syncable) {
    ((Syncable) out).hsync();
  } else {
    out.flush();
  }
}
 
Example #9
Source File: CryptoOutputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void hflush() throws IOException {
  flush();
  if (out instanceof Syncable) {
    ((Syncable)out).hflush();
  }
}
 
Example #10
Source File: CryptoOutputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void hsync() throws IOException {
  flush();
  if (out instanceof Syncable) {
    ((Syncable)out).hsync();
  }
}
 
Example #11
Source File: FileSystemWAL.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
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();
    }
  }
}
 
Example #12
Source File: HdfsSyncThread.java    From pulsar with Apache License 2.0 4 votes vote down vote up
public HdfsSyncThread(Syncable stream, BlockingQueue<Record<V>> unackedRecords, long syncInterval) {
  this.stream = stream;
  this.unackedRecords = unackedRecords;
  this.syncInterval = syncInterval;
}
 
Example #13
Source File: HdfsSyncThread.java    From pulsar with Apache License 2.0 4 votes vote down vote up
public HdfsSyncThread(Syncable stream, BlockingQueue<Record<V>> unackedRecords, long syncInterval) {
  this.stream = stream;
  this.unackedRecords = unackedRecords;
  this.syncInterval = syncInterval;
}