public Pair<IndexEntry, IndexEntry> lookupLastLogIndexAndPosFromTail() {
        final long lastLogIndex = getLastLogIndex();
        final long firstLogIndex = getFirstLogIndex();
        IndexEntry lastSegmentIndex = null, lastConfIndex = null;
        long index = lastLogIndex;
        while (index >= firstLogIndex) {
            final IndexEntry indexEntry = lookupIndex(index);
            indexEntry.setLogIndex(index);
            if (indexEntry.getLogType() == IndexType.IndexSegment.getType() && lastSegmentIndex == null) {
                lastSegmentIndex = indexEntry;
            } else if (indexEntry.getLogType() == IndexType.IndexConf.getType() && lastConfIndex == null) {
                lastConfIndex = indexEntry;
            }
            if (lastSegmentIndex != null && lastConfIndex != null) {
                break;
            }
            index--;
        }
        return Pair.of(lastSegmentIndex, lastConfIndex);
    }
@Test
    public void testLookupLastLogIndexAndPosFromTail() {
        this.indexDB.startServiceManager();
        {
            this.indexDB.appendIndexAsync(1, 1, IndexType.IndexSegment);
            this.indexDB.appendIndexAsync(2, 2, IndexType.IndexSegment);
            final Pair<Integer, Long> posPair = this.indexDB.appendIndexAsync(3, 3, IndexType.IndexConf);
            this.indexDB.appendIndexAsync(4, 4, IndexType.IndexSegment);
            this.indexDB.waitForFlush(posPair.getSecond(), 100);
        }
        final Pair<IndexFile.IndexEntry, IndexFile.IndexEntry> indexPair = this.indexDB
            .lookupLastLogIndexAndPosFromTail();
        final IndexFile.IndexEntry lastSegmentIndex = indexPair.getFirst();
        final IndexFile.IndexEntry lastConfIndex = indexPair.getSecond();
        assert (lastSegmentIndex.getLogIndex() == 4);
        assert (lastConfIndex.getLogIndex() == 3);
    }