Package com.alibaba.druid.filter.stat

Examples of com.alibaba.druid.filter.stat.StatFilter


        Assert.assertEquals(2, dataSource.getConnectProperties().size());

        Assert.assertEquals("5", dataSource.getConnectProperties().getProperty("b"));
        Assert.assertEquals("6", dataSource.getConnectProperties().getProperty("c"));

        StatFilter filter = dataSource.unwrap(StatFilter.class);
        Assert.assertNotNull(filter);
        Assert.assertFalse(filter.isMergeSql());

        dataSource.setConnectionProperties("b=5;c=6;druid.stat.mergeSql=true");

        Assert.assertTrue(filter.isMergeSql());

        Assert.assertEquals(3, dataSource.getConnectProperties().size());

        Assert.assertEquals("true", dataSource.getConnectProperties().getProperty("druid.stat.mergeSql"));
        Assert.assertEquals("5", dataSource.getConnectProperties().getProperty("b"));
        Assert.assertEquals("6", dataSource.getConnectProperties().getProperty("c"));
       
        dataSource.setConnectionProperties("b=5;c=6;druid.stat.mergeSql=false");

        Assert.assertFalse(filter.isMergeSql());
       
        Assert.assertEquals("false", dataSource.getConnectProperties().getProperty("druid.stat.mergeSql"));
        Assert.assertEquals("5", dataSource.getConnectProperties().getProperty("b"));
        Assert.assertEquals("6", dataSource.getConnectProperties().getProperty("c"));
    }
View Full Code Here


        dataSource.setTestWhileIdle(false);
        System.setProperty("druid.stat.slowSqlMillis", "500");
        dataSource.setFilters("stat");
       
        {
            StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
            Assert.assertEquals(3000, filter.getSlowSqlMillis());
        }
        dataSource.init();
    }
View Full Code Here

        System.clearProperty("druid.stat.slowSqlMillis");
        dataSource.close();
    }

    public void test_connect() throws Exception {
        StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
        Assert.assertEquals(500, filter.getSlowSqlMillis());
    }
View Full Code Here

        Assert.assertEquals(2, dataSource.getConnectProperties().size());

        Connection conn = dataSource.getConnection();
        conn.close();

        StatFilter filter = dataSource.unwrap(StatFilter.class);
        Assert.assertNotNull(filter);
        Assert.assertFalse(filter.isMergeSql());
        Assert.assertEquals(234, dataSource.getDataSourceStat().getMaxSqlSize());

        dataSource.setConnectionProperties("druid.stat.mergeSql=true;druid.stat.sql.MaxSize=456");
        Assert.assertEquals(456, dataSource.getDataSourceStat().getMaxSqlSize());
       
        Assert.assertTrue(filter.isMergeSql());

        Assert.assertEquals(2, dataSource.getConnectProperties().size());

        Assert.assertEquals("true", dataSource.getConnectProperties().getProperty("druid.stat.mergeSql"));

        dataSource.setConnectionProperties("druid.stat.mergeSql=false");

        Assert.assertFalse(filter.isMergeSql());

        Assert.assertEquals("false", dataSource.getConnectProperties().getProperty("druid.stat.mergeSql"));
    }
View Full Code Here

        dataSourceB = new DruidDataSource();

        dataSourceA.setUrl("jdbc:mock:xxx_A");
        dataSourceB.setUrl("jdbc:mock:xxx_B");
       
        StatFilter filter = new StatFilter();
       
        dataSourceA.getProxyFilters().add(filter);
        dataSourceB.getProxyFilters().add(filter);

        dataSourceA.init();
View Full Code Here

    protected void tearDown() throws Exception {
        dataSource.close();
    }

    public void test_connect() throws Exception {
        StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
        Assert.assertEquals(500, filter.getSlowSqlMillis());
    }
View Full Code Here

            return conn;
        }
    }

    public CompositeDataSupport getCompositeData() throws JMException {
        StatFilter statFilter = null;
        JdbcDataSourceStat stat = null;
        for (Filter filter : this.getProxyFilters()) {
            if (filter instanceof StatFilter) {
                statFilter = (StatFilter) filter;
            }
        }
        if (statFilter != null) {
            stat = statFilter.getDataSourceStat();
        }

        Map<String, Object> map = new HashMap<String, Object>();

        map.put("ID", getID());
View Full Code Here

        final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources();
        for (DataSourceProxyImpl dataSource : dataSources.values()) {
            for (Filter filter : dataSource.getConfig().getFilters()) {
                if (filter instanceof StatFilter) {
                    StatFilter countFilter = (StatFilter) filter;

                    ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = countFilter.getConnections();
                    for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) {
                        data.put(entry.getValue().getCompositeData());
                    }
                }
            }
        }

        for (DruidDataSource instance : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
            for (Filter filter : instance.getProxyFilters()) {
                if (filter instanceof StatFilter) {
                    StatFilter countFilter = (StatFilter) filter;

                    ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = countFilter.getConnections();
                    for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) {
                        data.put(entry.getValue().getCompositeData());
                    }
                }
            }
View Full Code Here

        final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources();
        for (DataSourceProxyImpl dataSource : dataSources.values()) {
            for (Filter filter : dataSource.getConfig().getFilters()) {
                if (filter instanceof StatFilter) {
                    StatFilter countFilter = (StatFilter) filter;
                    countFilter.reset();
                }
            }
        }

        for (DruidDataSource instance : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
            for (Filter filter : instance.getProxyFilters()) {
                if (filter instanceof StatFilter) {
                    StatFilter countFilter = (StatFilter) filter;
                    countFilter.reset();
                }
            }
        }
    }
View Full Code Here

            return conn;
        }
    }

    public CompositeDataSupport getCompositeData() throws JMException {
        StatFilter statFilter = null;
        JdbcDataSourceStat stat = null;
        for (Filter filter : this.getProxyFilters()) {
            if (filter instanceof StatFilter) {
                statFilter = (StatFilter) filter;
            }
        }
        if (statFilter != null) {
            stat = statFilter.getDataSourceStat();
        }

        Map<String, Object> map = new HashMap<String, Object>();

        map.put("ID", getID());
View Full Code Here

TOP

Related Classes of com.alibaba.druid.filter.stat.StatFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.