public void flushAndClose() throws IOException {
  if (isClosed.get() == false) {
    logger.trace("flushAndClose now acquire writeLock");
    try (ReleasableLock lock=writeLock.acquire()){
      logger.trace("flushAndClose now acquired writeLock");
      try {
        logger.debug("flushing shard on close - this might take some time to sync files to disk");
        try {
          flush();
        }
 catch (        FlushNotAllowedEngineException ex) {
          logger.debug("flush not allowed during flushAndClose - skipping");
        }
catch (        EngineClosedException ex) {
          logger.debug("engine already closed - skipping flushAndClose");
        }
      }
  finally {
        close();
      }
    }
   }
}

public void flushAndClose ( ) throws IOException { if ( isClosed . get ( ) == false ) { logger . trace ( "flushAndClose now acquire writeLock" ) ; try ( ReleasableLock lock = writeLock . acquire ( ) ) { logger . trace ( "flushAndClose now acquired writeLock" ) ; try { logger . debug ( "flushing shard on close - this might take some time to sync files to disk" ) ; try { flush ( ) ; } catch ( FlushNotAllowedEngineException ex ) { logger . debug ( "flush not allowed during flushAndClose - skipping" ) ; } catch ( EngineClosedException ex ) { logger . debug ( "engine already closed - skipping flushAndClose" ) ; } } finally { close ( ) ; } } } }
flush the engine ( committing segments to disk and truncating the translog ) and close it .
