public int getNumBes() {
        return Math.max(numHardwareCoresPerBe.size(), memLimitBytesPerBe.size());
    }
@Test
    public void testGetNumBes() {
        BackendResourceStat stat = BackendResourceStat.getInstance();

        stat.setNumHardwareCoresOfBe(0L, 8);
        assertThat(stat.getNumBes()).isEqualTo(1);

        stat.setNumHardwareCoresOfBe(1L, 4);
        assertThat(stat.getNumBes()).isEqualTo(2);

        stat.setNumHardwareCoresOfBe(0L, 16);
        assertThat(stat.getNumBes()).isEqualTo(2);

        stat.setMemLimitBytesOfBe(0L, 100);
        assertThat(stat.getNumBes()).isEqualTo(2);

        stat.setMemLimitBytesOfBe(1L, 50);
        assertThat(stat.getNumBes()).isEqualTo(2);

        stat.setMemLimitBytesOfBe(3L, 50);
        assertThat(stat.getNumBes()).isEqualTo(3);

        // Remove non-exist BE.
        stat.removeBe(4L);
        assertThat(stat.getNumBes()).isEqualTo(3);

        // Remove exist BE.
        stat.removeBe(3L);
        assertThat(stat.getNumBes()).isEqualTo(2);
        stat.removeBe(0L);
        assertThat(stat.getNumBes()).isEqualTo(1);

        stat.reset();
        assertThat(stat.getNumBes()).isZero();
    }