public void removeBe(long be) {
        if (numHardwareCoresPerBe.remove(be) != null) {
            cachedAvgNumHardwareCores.set(-1);
        }
        LOG.info("remove numHardwareCores of be [{}], current cpuCores stats: {}", be, numHardwareCoresPerBe);

        if (memLimitBytesPerBe.remove(be) != null) {
            cachedAvgMemLimitBytes.set(-1);
        }
    }
@Test
    public void testRemoveBe() {
        BackendResourceStat stat = BackendResourceStat.getInstance();

        stat.setNumHardwareCoresOfBe(0L, 8);
        stat.setNumHardwareCoresOfBe(1L, 4);
        assertThat(stat.getAvgNumHardwareCoresOfBe()).isEqualTo(6);

        stat.setMemLimitBytesOfBe(0L, 100);
        stat.setMemLimitBytesOfBe(1L, 50);
        assertThat(stat.getAvgMemLimitBytes()).isEqualTo(150 / 2);
        assertThat(stat.getAvgNumHardwareCoresOfBe()).isEqualTo(6);

        // Remove non-exist BE.
        stat.removeBe(3L);
        assertThat(stat.getAvgMemLimitBytes()).isEqualTo(150 / 2);
        assertThat(stat.getAvgNumHardwareCoresOfBe()).isEqualTo(6);

        // Remove exist BE.
        stat.removeBe(0L);
        assertThat(stat.getAvgMemLimitBytes()).isEqualTo(50);
        assertThat(stat.getAvgNumHardwareCoresOfBe()).isEqualTo(4);
    }