Codota Logo
ResilientFileOutputStream.getChannel
Code IndexAdd Codota to your IDE (free)

How to use
getChannel
method
in
ch.qos.logback.core.recovery.ResilientFileOutputStream

Best Java code snippets using ch.qos.logback.core.recovery.ResilientFileOutputStream.getChannel (Showing top 11 results out of 315)

  • Common ways to obtain ResilientFileOutputStream
private void myMethod () {
ResilientFileOutputStream r =
  • Codota IconFile file;new ResilientFileOutputStream(file, append)
  • Codota IconFile file;FileSize fileSize;new ResilientFileOutputStream(file, append, fileSize.getSize())
  • Smart code suggestions by Codota
}
origin: camunda/camunda-bpm-platform

private void safeWrite(E event) throws IOException {
 ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
 FileChannel fileChannel = resilientFOS.getChannel();
 if (fileChannel == null) {
  return;
 }
 FileLock fileLock = null;
 try {
  fileLock = fileChannel.lock();
  long position = fileChannel.position();
  long size = fileChannel.size();
  if (size != position) {
   fileChannel.position(size);
  }
  super.writeOut(event);
 } finally {
  if (fileLock != null) {
   fileLock.release();
  }
 }
}
origin: stackoverflow.com

 public class MyFileAppender<E> extends FileAppender<E> {
  protected void writeOut(E event) throws IOException {
    super.writeOut(event);
    ResilientFileOutputStream resilientFos = (ResilientFileOutputStream) super.getOutputStream();
    resilientFos.flush();
    resilientFos.getChannel().force(true);
  }
}
origin: at.bestsolution.efxclipse.eclipse/ch.qos.logback.core

private void safeWrite(E event) throws IOException {
 ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
 FileChannel fileChannel = resilientFOS.getChannel();
 if (fileChannel == null) {
  return;
 }
 FileLock fileLock = null;
 try {
  fileLock = fileChannel.lock();
  long position = fileChannel.position();
  long size = fileChannel.size();
  if (size != position) {
   fileChannel.position(size);
  }
  super.writeOut(event);
 } finally {
  if (fileLock != null) {
   fileLock.release();
  }
 }
}
origin: ch.qos.logback/core

private void safeWrite(E event) throws IOException {
 ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
 FileChannel fileChannel = resilientFOS.getChannel();
 if (fileChannel == null) {
  return;
 }
 FileLock fileLock = null;
 try {
  fileLock = fileChannel.lock();
  long position = fileChannel.position();
  long size = fileChannel.size();
  if (size != position) {
   fileChannel.position(size);
  }
  super.writeOut(event);
 } finally {
  if (fileLock != null) {
   fileLock.release();
  }
 }
}
origin: tony19/logback-android

private void safeWrite(E event) throws IOException {
 ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
 FileChannel fileChannel = resilientFOS.getChannel();
 if (fileChannel == null) {
  return;
 }
 // Clear any current interrupt (see LOGBACK-875)
 boolean interrupted = Thread.interrupted();
 FileLock fileLock = null;
 try {
  fileLock = fileChannel.lock();
  long position = fileChannel.position();
  long size = fileChannel.size();
  if (size != position) {
   fileChannel.position(size);
  }
  super.writeOut(event);
 } catch (IOException e) {
  // Mainly to catch FileLockInterruptionExceptions (see LOGBACK-875)
  resilientFOS.postIOFailure(e);
 } finally {
  if (fileLock != null && fileLock.isValid()) {
   fileLock.release();
  }
  // Re-interrupt if we started in an interrupted state (see LOGBACK-875)
  if (interrupted) {
   Thread.currentThread().interrupt();
  }
 }
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private void safeWrite(E event) throws IOException {
  ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
  FileChannel fileChannel = resilientFOS.getChannel();
  if (fileChannel == null) {
    return;
  }
  // Clear any current interrupt (see LOGBACK-875)
  boolean interrupted = Thread.interrupted();
  FileLock fileLock = null;
  try {
    fileLock = fileChannel.lock();
    long position = fileChannel.position();
    long size = fileChannel.size();
    if (size != position) {
      fileChannel.position(size);
    }
    super.writeOut(event);
  } catch (IOException e) {
    // Mainly to catch FileLockInterruptionExceptions (see LOGBACK-875)
    resilientFOS.postIOFailure(e);
  } finally {
    if (fileLock != null && fileLock.isValid()) {
      fileLock.release();
    }
    // Re-interrupt if we started in an interrupted state (see LOGBACK-875)
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
origin: Nextdoor/bender

private void safeWrite(E event) throws IOException {
  ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
  FileChannel fileChannel = resilientFOS.getChannel();
  if (fileChannel == null) {
    return;
  }
  // Clear any current interrupt (see LOGBACK-875)
  boolean interrupted = Thread.interrupted();
  FileLock fileLock = null;
  try {
    fileLock = fileChannel.lock();
    long position = fileChannel.position();
    long size = fileChannel.size();
    if (size != position) {
      fileChannel.position(size);
    }
    super.writeOut(event);
  } catch (IOException e) {
    // Mainly to catch FileLockInterruptionExceptions (see LOGBACK-875)
    resilientFOS.postIOFailure(e);
  } finally {
    if (fileLock != null && fileLock.isValid()) {
      fileLock.release();
    }
    // Re-interrupt if we started in an interrupted state (see LOGBACK-875)
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
origin: com.hynnet/logback-core

private void safeWrite(E event) throws IOException {
 ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
 FileChannel fileChannel = resilientFOS.getChannel();
 if (fileChannel == null) {
  return;
origin: io.virtdata/virtdata-lib-realer

private void safeWrite(E event) throws IOException {
  ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
  FileChannel fileChannel = resilientFOS.getChannel();
  if (fileChannel == null) {
    return;
  }
  // Clear any current interrupt (see LOGBACK-875)
  boolean interrupted = Thread.interrupted();
  FileLock fileLock = null;
  try {
    fileLock = fileChannel.lock();
    long position = fileChannel.position();
    long size = fileChannel.size();
    if (size != position) {
      fileChannel.position(size);
    }
    super.writeOut(event);
  } catch (IOException e) {
    // Mainly to catch FileLockInterruptionExceptions (see LOGBACK-875)
    resilientFOS.postIOFailure(e);
  } finally {
    if (fileLock != null && fileLock.isValid()) {
      fileLock.release();
    }
    // Re-interrupt if we started in an interrupted state (see LOGBACK-875)
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
origin: tony19/logback-android

 private void closeLogFileOnPurpose() throws IOException {
  ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) fa
   .getOutputStream();
  FileChannel fileChannel = resilientFOS.getChannel();
  fileChannel.close();
 }
}
origin: tony19/logback-android

@Test
public void verifyRecuperationAfterFailure() throws Exception {
 File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX+"resilient"+diff+".log");
 ResilientFileOutputStream rfos = new ResilientFileOutputStream(file, true, FileAppender.DEFAULT_BUFFER_SIZE);
 rfos.setContext(context);
 ResilientFileOutputStream spy = spy(rfos);
 spy.write("a".getBytes());
 spy.flush();
 spy.getChannel().close();
 spy.write("b".getBytes());
 spy.flush();
 Thread.sleep(RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN+10);
 spy.write("c".getBytes());
 spy.flush();
 verify(spy).openNewOutputStream();
}
ch.qos.logback.core.recoveryResilientFileOutputStreamgetChannel

Popular methods of ResilientFileOutputStream

  • <init>
  • setContext
  • postIOFailure
  • flush
  • getFile
  • openNewOutputStream
  • write

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • putExtra (Intent)
  • onCreateOptionsMenu (Activity)
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now