core/src/main/java/org/elasticsearch/index/translog/Translog.java
public Translog.Operation read(Location location) {
        try (ReleasableLock lock = readLock.acquire()) {
            final BaseTranslogReader reader;
            final long currentGeneration = current.getGeneration();
            if (currentGeneration == location.generation) {
                reader = current;
            } else if (readers.isEmpty() == false && readers.get(readers.size() - 1).getGeneration() == location.generation) {
                reader = readers.get(readers.size() - 1);
            } else if (currentGeneration < location.generation) {
                throw new IllegalStateException("location generation [" + location.generation + "] is greater than the current generation [" + currentGeneration + "]");
            } else {
                return null;
            }
            return reader.read(location);
        } catch (IOException e) {
            throw new ElasticsearchException("failed to read source from translog location " + location, e);
        }
    }
/**
     * Read the Operation object from the given location. This method will try to read the given location from
     * the current or from the currently committing translog file. If the location is in a file that has already
     * been closed or even removed the method will return <code>null</code> instead.
     */
Read the Operation object from the given location. This method will try to read the given location from
the current or from the currently committing translog file. If the location is in a file that has already
been closed or even removed the method will return null instead.
Read the Operation object from the given location . This method will try to read the given location from the current or from the currently committing translog file . If the location is in a file that has already been closed or even removed the method will return null instead .
public Translog.Operation read(Location location) {
        try (ReleasableLock lock = readLock.acquire()) {
            final BaseTranslogReader reader;
            final long currentGeneration = current.getGeneration();
            if (currentGeneration == location.generation) {
                reader = current;
            } else if (readers.isEmpty() == false && readers.get(readers.size() - 1).getGeneration() == location.generation) {
                reader = readers.get(readers.size() - 1);
            } else if (currentGeneration < location.generation) {
                throw new IllegalStateException("location generation [" + location.generation + "] is greater than the current generation [" + currentGeneration + "]");
            } else {
                return null;
            }
            return reader.read(location);
        } catch (IOException e) {
            throw new ElasticsearchException("failed to read source from translog location " + location, e);
        }
    }
public Translog . Operation read ( Location location ) { try ( ReleasableLock lock = readLock . acquire ( ) ) { final BaseTranslogReader reader ; final long currentGeneration = current . getGeneration ( ) ; if ( currentGeneration == location . generation ) { reader = current ; } else if ( readers . isEmpty ( ) == false && readers . get ( readers . size ( ) - 1 ) . getGeneration ( ) == location . generation ) { reader = readers . get ( readers . size ( ) - 1 ) ; } else if ( currentGeneration < location . generation ) { throw new IllegalStateException ( "location generation [" + location . generation + "] is greater than the current generation [" + currentGeneration + "]" ) ; } else { return null ; } return reader . read ( location ) ; } catch ( IOException e ) { throw new ElasticsearchException ( "failed to read source from translog location " + location , e ) ; } }
Read the Operation object from the given location.
Read the Operation object from the given location .