public void removeDataSources() {
        if (nodesToDel == null || nodesToDel.isEmpty()) {
            return;
        }

        lock.lock();
        try {
            Map<String, DataSource> map = highAvailableDataSource.getDataSourceMap();
            Set<String> copySet = new HashSet<String>(nodesToDel);
            for (String nodeName : copySet) {
                LOG.info("Start removing Node " + nodeName + ".");
                if (!map.containsKey(nodeName)) {
                    LOG.info("Node " + nodeName + " is NOT existed in the map.");
                    cancelBlacklistNode(nodeName);
                    continue;
                }
                DataSource ds = map.get(nodeName);
                if (ds instanceof DruidDataSource) {
                    DruidDataSource dds = (DruidDataSource) ds;
                    int activeCount = dds.getActiveCount(); // CAUTION, activeCount MAYBE changed!
                    if (activeCount > 0) {
                        LOG.warn("Node " + nodeName + " is still running [activeCount=" + activeCount
                                + "], try next time.");
                        continue;
                    } else {
                        LOG.info("Close Node " + nodeName + " and remove it.");
                        try {
                            dds.close();
                        } catch (Exception e) {
                            LOG.error("Exception occurred while closing Node " + nodeName
                                    + ", just remove it.", e);
                        }
                    }
                }
                map.remove(nodeName); // Remove the node directly if it is NOT a DruidDataSource.
                cancelBlacklistNode(nodeName);
            }
        } catch (Exception e) {
            LOG.error("Exception occurred while removing DataSources.", e);
        } finally {
            lock.unlock();
        }
    }
@Test
    public void testRemoveDataSources() {
        String url = "jdbc:derby:memory:foo;create=true";
        String name = "foo";
        addNode(url, name);
        DruidDataSource ds = (DruidDataSource) haDataSource.getDataSourceMap().get(name);

        updater.getNodesToDel().add(name);
        haDataSource.addBlackList(name);

        updater.removeDataSources();
        assertTrue(haDataSource.getDataSourceMap().isEmpty());
        assertFalse(haDataSource.isInBlackList(name));
        assertTrue(ds.isClosed());
    }