class MysqlServerController {

  public String moveData(String pathOfMysqlData, long expireTimeOfOldMysqlData) throws IOException {
    File fileOfMysqlData = new File(pathOfMysqlData).getAbsoluteFile();
    if (!fileOfMysqlData.exists()) {
      Utilities.logInfo(logger, "no need to move not existed path=", pathOfMysqlData);
      return null;
    }
    try {
      String newPathOfMysqlData =
          pathOfMysqlData + "-" + Utilities.longTimeToStringTime(System.currentTimeMillis(), "");
      fileOfMysqlData.renameTo(new File(newPathOfMysqlData));
      File parentFileOfMysqlData = fileOfMysqlData.getParentFile();
      for (File oldFileOfMysqlData : parentFileOfMysqlData.listFiles()) {
        if (oldFileOfMysqlData.getName().startsWith(fileOfMysqlData.getName())) {
          String timeString = oldFileOfMysqlData.getName().substring(fileOfMysqlData.getName().length());
          if (!timeString.startsWith("-")) continue;
          timeString = timeString.substring(1);
          long time = Utilities.stringTimeToLongTime(timeString, "");
          if (System.currentTimeMillis() - time > expireTimeOfOldMysqlData) {
            Utilities.delete(oldFileOfMysqlData);
            Utilities.logInfo(logger, "delete ", oldFileOfMysqlData);
          }
        }
      }
      Utilities.logInfo(logger, "move ", pathOfMysqlData, " to ", newPathOfMysqlData);
      return newPathOfMysqlData;
    } catch (Throwable t) {
      throw new IOException(t);
    }
  }

}