public void setLeader(int clusterId, String token, long epoch) {
        TMasterInfo tMasterInfo = new TMasterInfo(new TNetworkAddress(FrontendOptions.getLocalHostAddress(), Config.rpc_port),
                epoch);
        tMasterInfo.setCluster_id(clusterId);
        tMasterInfo.setToken(token);
        tMasterInfo.setHttp_port(Config.http_port);
        long flags = HeartbeatFlags.getHeartbeatFlags();
        tMasterInfo.setHeartbeat_flags(flags);
        tMasterInfo.setMin_active_txn_id(GlobalStateMgr.getCurrentState().getGlobalTransactionMgr().getMinActiveTxnId());
        tMasterInfo.setEncrypted(KeyMgr.isEncrypted());
        MASTER_INFO.set(tMasterInfo);
    }
@Test
    public void testBackendHandler(@Mocked HeartbeatService.Client client) throws Exception {
        TStatus status = new TStatus(TStatusCode.ABORTED);
        status.setError_msgs(Collections.singletonList("error_msg"));
        THeartbeatResult res = new THeartbeatResult();
        res.setStatus(status);

        new MockUp<ThriftConnectionPool<?>>() {
            @Mock
            public HeartbeatService.Client borrowObject(TNetworkAddress address, int timeoutMs) throws Exception {
                return client;
            }

            @Mock
            public void returnObject(TNetworkAddress address, HeartbeatService.Client object) {
            }

            @Mock
            public void invalidateObject(TNetworkAddress address, HeartbeatService.Client object) {
            }
        };

        new MockUp<RunMode>() {
            @Mock
            public RunMode getCurrentRunMode() {
                return RunMode.SHARED_DATA;
            }
        };

        new MockUp<HeartbeatMgr>() {
            @Mock
            public long computeMinActiveTxnId() {
                return 100L;
            }
        };

        new Expectations() {
            {
                client.heartbeat((TMasterInfo) any);
                minTimes = 1;
                result = res;
            }
        };

        // call setLeader() to init the MASTER_INFO
        new HeartbeatMgr(false).setLeader(1, "123", 1);

        ComputeNode cn = new ComputeNode(1, "192.168.1.1", 8111);
        HeartbeatMgr.BackendHeartbeatHandler handler = new HeartbeatMgr.BackendHeartbeatHandler(cn);
        HeartbeatResponse response = handler.call();
        Assert.assertTrue(response instanceof BackendHbResponse);
        BackendHbResponse hbResponse = (BackendHbResponse) response;
        Assert.assertEquals(HbStatus.BAD, hbResponse.getStatus());

        new Verifications() {
            {
                TMasterInfo masterInfo;
                client.heartbeat(masterInfo = withCapture());
                // verify the runMode is set in the masterInfo request
                Assert.assertNotNull(masterInfo);
                Assert.assertEquals(TRunMode.SHARED_DATA, masterInfo.getRun_mode());
            }
        };
    }