@Override
    public boolean switchFile(String newFile, long startPoint) {
        logger.info("Switch binary log file now, from " + currentFileName + " to " + newFile);
        logger.info("Previous end point is " + currentFileName);
        if (logFileStream != null && currentFileName != null) {
            try {
                logFileStream.close();
            } catch (IOException e) {
                logger.warn("Fail to close binary log file : " + currentFileName, e);
            }
        }
        boolean isValidLogFile = false;
        try {
            logFileStream = new FileInputStream(newFile);
            isValidLogFile = validateLogFile();
            if(isValidLogFile) {
                logFileStream.skip(startPoint - 4);// skip unused bytes, usually it is 4;
            } else {
                logFileStream.close();
            }
        } catch (FileNotFoundException ex) {
            logger.error("Fail to find new binary log file : " + newFile, ex);
        } catch (IOException ex) {
            logger.error("Fail to access new binary log file: " + newFile, ex);
        }
        if(!isValidLogFile) {
            logger.error("Invalid binary log file, file path:" + newFile);
            throw new RuntimeException("Invalid binary log file, file path:" + newFile);
        }
        lastPointer = startPoint;
        logger.info("New file start point is " + startPoint);
        return true;
    }