Tabnine Logo
ResilientFileOutputStream.getChannel
Code IndexAdd Tabnine 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)

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

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now