@Override public void trim(final long position){
  if (!setup) {
    throw new IllegalStateException("not setup");
  }
synchronized (lock) {
    final Iterator<Header> iter=headers.iterator();
    final List<Header> unlink=Lists.newArrayList();
    Header current=iter.next();
    while (iter.hasNext()) {
      final Header next=iter.next();
      if (next.offset() >= position) {
        break;
      }
      unlink.add(current);
      current=next;
    }
    for (    final Header m : unlink) {
      headers.remove(m);
      log.info("Unlinking {}",m);
      try {
        Files.delete(m.path());
      }
 catch (      IOException e) {
        log.error("Failed to unlink {}",m,e);
      }
    }
  }
}

@ Override public void trim ( final long position ) { if ( ! setup ) { throw new IllegalStateException ( "not setup" ) ; } synchronized ( lock ) { final Iterator < Header > iter = headers . iterator ( ) ; final List < Header > unlink = Lists . newArrayList ( ) ; Header current = iter . next ( ) ; while ( iter . hasNext ( ) ) { final Header next = iter . next ( ) ; if ( next . offset ( ) >= position ) { break ; } unlink . add ( current ) ; current = next ; } for ( final Header m : unlink ) { headers . remove ( m ) ; log . info ( "Unlinking {}" , m ) ; try { Files . delete ( m . path ( ) ) ; } catch ( IOException e ) { log . error ( "Failed to unlink {}" , m , e ) ; } } } }
trim the head of the on - disk log ( if necessary ) .
