public void registerNodeHeartbeat(NodeStatus nodeStatus)
    {
        requireNonNull(nodeStatus, "nodeStatus is null");
        InternalNodeState nodeState = nodeStatuses.get(nodeStatus.getNodeId());
        if (nodeState == null) {
            nodeStatuses.put(nodeStatus.getNodeId(), new InternalNodeState(nodeStatus));
        }
        else {
            nodeState.updateNodeStatus(nodeStatus);
        }
    }
@Test(timeOut = 20_000)
    public void testWorkerMemoryInfo()
            throws Exception
    {
        ResourceManagerClusterStateProvider provider = new ResourceManagerClusterStateProvider(new InMemoryNodeManager(), new SessionPropertyManager(), 10, Duration.valueOf("4s"), Duration.valueOf("8s"), Duration.valueOf("5s"), Duration.valueOf("0s"), Duration.valueOf("4s"), true, newSingleThreadScheduledExecutor());

        assertWorkerMemoryInfo(provider, 0);

        provider.registerNodeHeartbeat(createNodeStatus("nodeId", GENERAL_POOL, createMemoryPoolInfo(100, 2, 1)));
        assertWorkerMemoryInfo(provider, 1);

        provider.registerNodeHeartbeat(createNodeStatus("nodeId2", GENERAL_POOL, createMemoryPoolInfo(200, 20, 10)));
        assertWorkerMemoryInfo(provider, 2);

        // Node expiration timeout was set as 4 seconds
        // Waiting for the expiration to cross the threshold + adding buffer to avoid flakiness
        Thread.sleep(SECONDS.toMillis(10));

        assertWorkerMemoryInfo(provider, 0);
    }