@Override
    public void update(Observable o, Object arg) {
        if (!(o instanceof NodeListener)) {
            return;
        }
        if (arg == null || !(arg instanceof NodeEvent[])) {
            return;
        }
        NodeEvent[] events = (NodeEvent[]) arg;

        if (events.length <= 0) {
            return;
        }

        LOG.info("Waiting for Lock to start processing NodeEvents.");
        lock.lock();
        try {
            LOG.info("Start processing the NodeEvent[" + events.length + "].");
            for (NodeEvent e : events) {
                if (e.getType() == NodeEventTypeEnum.ADD) {
                    addNode(e);
                } else if (e.getType() == NodeEventTypeEnum.DELETE) {
                    deleteNode(e);
                }
            }
        } catch (Exception e) {
            LOG.error("Exception occurred while updating Pool.", e);
        } finally {
            lock.unlock();
        }
    }
@Test
    public void testUpdate() {
        updater.init();
        assertTrue(updater.isInited());
        haDataSource.getDataSourceMap().put("foo", new MockDataSource("foo"));
        haDataSource.getDataSourceMap().put("bar", new MockDataSource("bar"));

        NodeEvent event = new NodeEvent();
        event.setNodeName("foo");
        event.setType(NodeEventTypeEnum.DELETE);

        updater.update(new FileNodeListener(), new NodeEvent[]{event});
        validateDeleteNode();

        event = new NodeEvent();
        event.setNodeName("foo");
        event.setType(NodeEventTypeEnum.ADD);
        updater.update(new FileNodeListener(), new NodeEvent[]{event});
        assertFalse(updater.getNodesToDel().contains("foo"));
        assertFalse(haDataSource.isInBlackList("foo"));
    }