@Override
    public FailoverSwitch getSwitch() {
        try {
            File switchFile = Paths.get(failoverDir, UtilAndComs.FAILOVER_SWITCH).toFile();
            if (!switchFile.exists()) {
                NAMING_LOGGER.debug("failover switch is not found, {}", switchFile.getName());
                switchParams.put(FAILOVER_MODE_PARAM, Boolean.FALSE.toString());
                return FAILOVER_SWITCH_FALSE;
            }
            
            long modified = switchFile.lastModified();
            
            if (lastModifiedMillis < modified) {
                lastModifiedMillis = modified;
                String failover = ConcurrentDiskUtil.getFileContent(switchFile.getPath(), Charset.defaultCharset().toString());
                if (!StringUtils.isEmpty(failover)) {
                    String[] lines = failover.split(DiskCache.getLineSeparator());
                    
                    for (String line : lines) {
                        String line1 = line.trim();
                        if (IS_FAILOVER_MODE.equals(line1)) {
                            switchParams.put(FAILOVER_MODE_PARAM, Boolean.TRUE.toString());
                            NAMING_LOGGER.info("failover-mode is on");
                            new FailoverFileReader().run();
                            return FAILOVER_SWITCH_TRUE;
                        } else if (NO_FAILOVER_MODE.equals(line1)) {
                            switchParams.put(FAILOVER_MODE_PARAM, Boolean.FALSE.toString());
                            NAMING_LOGGER.info("failover-mode is off");
                            return FAILOVER_SWITCH_FALSE;
                        }
                    }
                }
            }
            return switchParams.get(FAILOVER_MODE_PARAM).equals(Boolean.TRUE.toString()) ? FAILOVER_SWITCH_TRUE : FAILOVER_SWITCH_FALSE;
            
        } catch (Throwable e) {
            NAMING_LOGGER.error("[NA] failed to read failover switch.", e);
            switchParams.put(FAILOVER_MODE_PARAM, Boolean.FALSE.toString());
            return FAILOVER_SWITCH_FALSE;
        }
    }
@Test
    void testGetSwitchForFailoverDisabledKeep() throws NoSuchFieldException, IllegalAccessException {
        String dir = DiskFailoverDataSourceTest.class.getResource("/").getPath() + "/failover_test/disabled";
        injectFailOverDir(dir);
        assertFalse(dataSource.getSwitch().getEnabled());
        assertFalse(dataSource.getSwitch().getEnabled());
    }