use of org.smartdata.server.metastore.DruidPool in project SSM by Intel-bigdata.
the class TestDruid method test.
@Test
public void test() throws Exception {
InputStream in = getClass().getClassLoader().getResourceAsStream("druid-template.xml");
Properties p = new Properties();
p.loadFromXML(in);
String dbFile = TestDBUtil.getUniqueEmptySqliteDBFile();
String url = Util.SQLITE_URL_PREFIX + dbFile;
p.setProperty("url", url);
DruidPool druidPool = new DruidPool(p);
DBAdapter adapter = new DBAdapter(druidPool);
String rule = "file : accessCountX(10m) > 20 \n\n" + "and length() > 3 | cachefile";
long submitTime = System.currentTimeMillis();
RuleInfo info1 = new RuleInfo(0, submitTime, rule, RuleState.ACTIVE, 0, 0, 0);
Assert.assertTrue(adapter.insertNewRule(info1));
RuleInfo info1_1 = adapter.getRuleInfo(info1.getId());
Assert.assertTrue(info1.equals(info1_1));
long now = System.currentTimeMillis();
adapter.updateRuleInfo(info1.getId(), RuleState.DELETED, now, 1, 1);
RuleInfo info1_2 = adapter.getRuleInfo(info1.getId());
Assert.assertTrue(info1_2.getLastCheckTime() == now);
druidPool.close();
}
use of org.smartdata.server.metastore.DruidPool in project SSM by Intel-bigdata.
the class SmartServer method getDBAdapter.
public DBAdapter getDBAdapter() throws Exception {
String fileName = "druid.xml";
URL urlPoolConf = getClass().getResource(fileName);
if (urlPoolConf != null) {
LOG.info("Using pool configure file: " + urlPoolConf.getFile());
Properties p = new Properties();
p.loadFromXML(getClass().getResourceAsStream(fileName));
return new DBAdapter(new DruidPool(p));
} else {
LOG.info(fileName + " NOT found.");
}
// TODO: keep it now for testing, remove it later.
Connection conn = getDBConnection();
return new DBAdapter(conn);
}
Aggregations