private String dumpLoadVerify(List<String> tableNames, String lastReplicationId,
                                boolean parallelLoad, boolean metadataOnly, boolean failRetry)
          throws Throwable {
    List<String> withClauseList;
    // Parallel load works only for bootstrap.
    parallelLoad = parallelLoad && (lastReplicationId == null);

    // With clause construction for REPL DUMP command.
    if (metadataOnly) {
      withClauseList = Collections.singletonList("'hive.repl.dump.metadata.only'='true'");
    } else {
      withClauseList = Collections.emptyList();
    }

    // Take dump
    WarehouseInstance.Tuple dumpTuple = primary.run("use " + primaryDbName)
            .dump(primaryDbName, withClauseList);


    // Load, if necessary changing configuration.
    if (parallelLoad) {
      replica.hiveConf.setBoolVar(HiveConf.ConfVars.EXEC_PARALLEL, true);
    }

    // Fail load if for testing failure and retry scenario. Fail the load while setting
    // checkpoint for a table in the middle of list of tables.
    if (failRetry) {
      if (lastReplicationId == null) {
        failBootstrapLoad(tableNames.size()/2);
      } else {
        failIncrementalLoad();
      }
    }
    
    Path baseDumpDir = new Path(primary.hiveConf.getVar(HiveConf.ConfVars.REPL_DIR));
    Path nonRecoverablePath = TestReplicationScenarios.getNonRecoverablePath(baseDumpDir, primaryDbName, primary.hiveConf);
    if(nonRecoverablePath != null){
      baseDumpDir.getFileSystem(primary.hiveConf).delete(nonRecoverablePath, true);
    }
    
    // Load, possibly a retry
    replica.load(replicatedDbName, primaryDbName);

    // Metadata load may not load all the events.
    if (!metadataOnly) {
      replica.run("repl status " + replicatedDbName)
              .verifyResult(dumpTuple.lastReplicationId);
    }

    if (parallelLoad) {
      replica.hiveConf.setBoolVar(HiveConf.ConfVars.EXEC_PARALLEL, false);
    }

    // Test statistics
    for (String name : tableNames) {
      if (metadataOnly) {
        verifyNoStatsReplicationForMetadataOnly(name);
      } else {
        verifyReplicatedStatsForTable(name);
      }
    }

    return dumpTuple.lastReplicationId;
  }
Dumps primarydb on primary, loads it on replica as replicadb, verifies that the statistics
loaded are same as the ones on primary.
@param tableNames, names of tables on primary expected to be loaded
@param parallelLoad, if true, parallel bootstrap load is used
@param metadataOnly, only metadata is dumped and loaded.
@param lastReplicationId of the last dump, for incremental dump/load
@param failRetry
@return lastReplicationId of the dump performed.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestStatsReplicationScenarios.java