private void createRepEnvInfo(String sleepTime) throws Throwable {

    /*
     * Set a large buffer size and disable the checkpointing, so the
     * data in the buffer can only be flushed by the LogFlushTask.
     */
    EnvironmentConfig envConfig = RepTestUtils.createEnvConfig(Durability.COMMIT_NO_SYNC);
    envConfig.setConfigParam(EnvironmentParams.MAX_MEMORY.getName(), "20000000");
    envConfig.setConfigParam(EnvironmentParams.LOG_MEM_SIZE.getName(), "120000000");
    envConfig.setConfigParam(EnvironmentParams.NUM_LOG_BUFFERS.getName(), "4");
    envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, "false");

    /* Configure the log flush task. */
    ReplicationConfig repConfig = new ReplicationConfig();
    repConfig.setConfigParam(ReplicationConfig.LOG_FLUSH_TASK_INTERVAL, sleepTime);
    repEnvInfo = RepTestUtils.setupEnvInfos(envRoot, 3, envConfig, repConfig);
  }
  private void openGroup() throws IOException {

    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);

    ReplicationConfig repConfig = new ReplicationConfig();
    repConfig.setConfigParam(RepParams.VLSN_LOG_CACHE_SIZE.getName(), "2");

    repEnvInfo = RepTestUtils.setupEnvInfos(envRoot, nNodes, envConfig, repConfig);
    master = RepTestUtils.joinGroup(repEnvInfo);

    StoreConfig config = new StoreConfig();
    config.setAllowCreate(true);
    config.setTransactional(true);
    store = new EntityStore(master, "test", config);
    primaryIndex = store.getPrimaryIndex(Integer.class, AppData.class);
  }
  /** Test the basic configuration of LogFlusher. */
  @Test
  public void testBasicConfig() throws Throwable {

    try {
      EnvironmentConfig envConfig = RepTestUtils.createEnvConfig(Durability.COMMIT_NO_SYNC);
      ReplicationConfig repConfig = new ReplicationConfig();
      repConfig.setConfigParam(ReplicationMutableConfig.LOG_FLUSH_TASK_INTERVAL, "30 s");
      repEnvInfo = RepTestUtils.setupEnvInfos(envRoot, 3, envConfig, repConfig);
      RepTestUtils.joinGroup(repEnvInfo);
      assertTrue(repEnvInfo[0].isMaster());
      /* Check the LogFlusher configuration. */
      TimerTask[] oldTasks = new TimerTask[repEnvInfo.length];
      for (int i = 0; i < repEnvInfo.length; i++) {
        LogFlusher flusher = repEnvInfo[i].getRepNode().getLogFlusher();
        oldTasks[i] = flusher.getFlushTask();
        assertTrue(flusher != null);
        assertTrue(flusher.getFlushTask() != null);
        assertTrue(flusher.getFlushInterval() == 30000);
      }

      /* Check that those configuratins are mutable. */
      repConfig.setConfigParam(ReplicationMutableConfig.LOG_FLUSH_TASK_INTERVAL, "50 s");
      for (int i = 0; i < repEnvInfo.length; i++) {
        repEnvInfo[i].getEnv().setRepMutableConfig(repConfig);
      }

      for (int i = 0; i < repEnvInfo.length; i++) {
        LogFlusher flusher = repEnvInfo[i].getRepNode().getLogFlusher();
        assertTrue(flusher != null);
        assertTrue(flusher.getFlushTask() != null);
        assertTrue(flusher.getFlushTask() != oldTasks[i]);
        assertTrue(flusher.getFlushInterval() == 50000);
      }

      repConfig.setConfigParam(ReplicationMutableConfig.RUN_LOG_FLUSH_TASK, "false");
      for (int i = 0; i < repEnvInfo.length; i++) {
        repEnvInfo[i].getEnv().setRepMutableConfig(repConfig);
      }

      for (int i = 0; i < repEnvInfo.length; i++) {
        LogFlusher flusher = repEnvInfo[i].getRepNode().getLogFlusher();
        assertTrue(flusher != null);
        assertTrue(flusher.getFlushTask() == null);
      }

      RepTestUtils.shutdownRepEnvs(repEnvInfo);
      RepTestUtils.removeRepEnvironments(envRoot);

      repConfig.setConfigParam(ReplicationConfig.RUN_LOG_FLUSH_TASK, "false");
      repEnvInfo = RepTestUtils.setupEnvInfos(envRoot, 3, envConfig, repConfig);
      RepTestUtils.joinGroup(repEnvInfo);
      /* Check that the task is disabled. */
      for (int i = 0; i < repEnvInfo.length; i++) {
        assertTrue(repEnvInfo[i].getRepNode().getLogFlusher() == null);
      }
    } catch (Throwable t) {
      t.printStackTrace();
      throw t;
    } finally {
      RepTestUtils.shutdownRepEnvs(repEnvInfo);
    }
  }