@Override
    public void refresh() throws JournalException, JournalInconsistentException, InterruptedException {
        // 1. refresh current db names
        List<Long> dbNames = null;
        JournalException exception = null;
        for (int i = 0; i < RETRY_TIME; ++ i) {
            if (i != 0) {
                Thread.sleep(SLEEP_INTERVAL_SEC * 1000L);
            }
            try {
                dbNames = environment.getDatabaseNamesWithPrefix(prefix);
                break;
            } catch (DatabaseException e) {
                String errMsg = String.format("failed to get DB names for %s times!", i + 1);
                exception = wrapDatabaseException(e, errMsg);
            }
        }
        if (dbNames == null) {
            if (exception != null) {
                throw exception;
            } else {
                throw new JournalException("failed to get db names!");
            }
        }

        // 2. no db changed ( roll new db / delete db after checkpoint )
        if (dbNames.equals(localDBNames)) {
            return;
        }

        // 3. update db index
        LOG.info("update dbNames {} -> {}", localDBNames, dbNames);
        localDBNames = dbNames;
        calculateNextDbIndex();
    }
@Test(expected = JournalException.class)
    public void refreshFailed(@Mocked BDBEnvironment environment) throws Exception {
        new Expectations(environment) {
            {
                environment.getDatabaseNamesWithPrefix("");
                result = new DatabaseNotFoundException("mock mock");
            }
        };
        BDBJEJournal journal = new BDBJEJournal(environment);
        JournalCursor cursor = journal.read(10, 10);
        cursor.refresh();
    }