public void start() {
		heartbeatExecutor.scheduleAtFixedRate(
				new Runnable() {
					@Override
					public void run() {
						// Because consul check set pass triggers consul
						// server write operation，frequently heart beat will impact consul
						// performance，so heart beat takes long cycle and switcher check takes short cycle.
						// multiple check on switcher and then send one heart beat to consul server.
						// TODO change to switcher listener approach.
						try {
							boolean switcherStatus = isHeartbeatOpen();
							if (isSwitcherChange(switcherStatus)) { // heart beat switcher status changed
								processHeartbeat(switcherStatus);
							} else {// heart beat switcher status not changed.
								if (switcherStatus) {// switcher is on, check MAX_SWITCHER_CHECK_TIMES and then send a heart beat
									switcherCheckTimes++;
									if (switcherCheckTimes >= PortalRegistryConstants.MAX_SWITCHER_CHECK_TIMES) {
										processHeartbeat(true);
										switcherCheckTimes = 0;
									}
								}
							}
						} catch (Exception e) {
							logger.error("consul heartbeat executor err:",
									e);
						}
					}
				}, PortalRegistryConstants.SWITCHER_CHECK_CIRCLE,
				PortalRegistryConstants.SWITCHER_CHECK_CIRCLE, TimeUnit.MILLISECONDS);
	}
@Test
    public void testStart() throws InterruptedException {
        heartbeatManager.start();
        Map<URL, Long> mockServices = new HashMap<URL, Long>();
        int serviceNum = 5;

        for (int i = 0; i < serviceNum; i++) {
            URL url = new URLImpl("light", "127.0.0.1", 7080, "com.networknt.petstore.v" + i);
            mockServices.put(url, 0L);
            heartbeatManager.addHeartbeatService(PortalRegistryUtils.buildService(url));
        }

        // switch on heart beat
        setHeartbeatSwitcher(true);
        checkHeartbeat(mockServices, true, serviceNum);

        // switch off heart beat
        setHeartbeatSwitcher(false);
        Thread.sleep(100);
        checkHeartbeat(mockServices, false, serviceNum);

    }