public int run() throws IOException {
    Set<MasterInfoField> masterInfoFilter = new HashSet<>(Arrays
        .asList(MasterInfoField.LEADER_MASTER_ADDRESS, MasterInfoField.WEB_PORT,
            MasterInfoField.RPC_PORT, MasterInfoField.START_TIME_MS,
            MasterInfoField.UP_TIME_MS, MasterInfoField.VERSION,
            MasterInfoField.SAFE_MODE, MasterInfoField.ZOOKEEPER_ADDRESSES,
            MasterInfoField.RAFT_JOURNAL, MasterInfoField.RAFT_ADDRESSES,
            MasterInfoField.MASTER_VERSION));
    MasterInfo masterInfo = mMetaMasterClient.getMasterInfo(masterInfoFilter);

    Set<BlockMasterInfoField> blockMasterInfoFilter = new HashSet<>(Arrays
        .asList(BlockMasterInfoField.LIVE_WORKER_NUM, BlockMasterInfoField.LOST_WORKER_NUM,
            BlockMasterInfoField.CAPACITY_BYTES, BlockMasterInfoField.USED_BYTES,
            BlockMasterInfoField.FREE_BYTES, BlockMasterInfoField.CAPACITY_BYTES_ON_TIERS,
            BlockMasterInfoField.USED_BYTES_ON_TIERS));
    BlockMasterInfo blockMasterInfo = mBlockMasterClient.getBlockMasterInfo(blockMasterInfoFilter);

    ObjectMapper objectMapper = new ObjectMapper();
    SummaryOutput summaryInfo = new SummaryOutput(masterInfo, blockMasterInfo);
    try {
      String json = objectMapper.writeValueAsString(summaryInfo);
      mPrintStream.println(json);
    } catch (JsonProcessingException e) {
      mPrintStream.println("Failed to convert summaryInfo output to JSON. "
          + "Check the command line log for the detailed error message.");
      LOG.error("Failed to output JSON object {}", summaryInfo);
      e.printStackTrace();
      return -1;
    }

    return 0;
  }
@Test
  public void RaftHaSummary() throws IOException {
    MasterVersion primaryVersion = MasterVersion.newBuilder()
        .setVersion(RuntimeConstants.VERSION).setState("Primary").setAddresses(
            NetAddress.newBuilder().setHost("hostname1").setRpcPort(10000).build()
        ).build();
    MasterVersion standby1Version = MasterVersion.newBuilder()
        .setVersion(RuntimeConstants.VERSION).setState("Standby").setAddresses(
            NetAddress.newBuilder().setHost("hostname2").setRpcPort(10001).build()
        ).build();
    MasterVersion standby2Version = MasterVersion.newBuilder()
        .setVersion(RuntimeConstants.VERSION).setState("Standby").setAddresses(
            NetAddress.newBuilder().setHost("hostname3").setRpcPort(10002).build()
        ).build();
    mMasterInfo = MasterInfo.newBuilder(mMasterInfo)
        .setRaftJournal(true)
        .addAllRaftAddress(Arrays.asList("[raftJournal_hostname1]:19200",
            "[raftJournal_hostname2]:19200", "[raftJournal_hostname3]:19200"))
        .addAllMasterVersions(Arrays.asList(primaryVersion, standby1Version, standby2Version))
        .build();
    when(mMetaMasterClient.getMasterInfo(any())).thenReturn(mMasterInfo);
    SummaryCommand summaryCommand = new SummaryCommand(mMetaMasterClient,
        mBlockMasterClient, sConf.getString(PropertyKey.USER_DATE_FORMAT_PATTERN), mPrintStream);
    summaryCommand.run();
    checkIfOutputValid(sConf.getString(PropertyKey.USER_DATE_FORMAT_PATTERN), "raft");
  }