Java Code Examples for org.apache.hadoop.fs.Syncable

The following examples show how to use org.apache.hadoop.fs.Syncable. These examples are extracted from open source projects. 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 Project: hadoop   Source File: CryptoStreamsTestBase.java    License: 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 Project: big-c   Source File: CryptoStreamsTestBase.java    License: 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 Project: hadoop   Source File: SyncableDataOutputStream.java    License: 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 Project: hadoop   Source File: SyncableDataOutputStream.java    License: 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 Project: hadoop   Source File: CryptoOutputStream.java    License: 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 Project: hadoop   Source File: CryptoOutputStream.java    License: 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 Project: big-c   Source File: SyncableDataOutputStream.java    License: 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 Project: big-c   Source File: SyncableDataOutputStream.java    License: 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 Project: big-c   Source File: CryptoOutputStream.java    License: 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 Project: big-c   Source File: CryptoOutputStream.java    License: 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 Project: attic-apex-malhar   Source File: FileSystemWAL.java    License: 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 Project: pulsar   Source File: HdfsSyncThread.java    License: 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 Project: pulsar   Source File: HdfsSyncThread.java    License: 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;
}