use of org.smartdata.common.rule.RuleInfo in project SSM by Intel-bigdata.
the class TestSubmitRuleThroughCli method test.
@Test
public void test() throws Exception {
waitTillSSMExitSafeMode();
String ruleFile = TestDBUtil.getUniqueFilePath();
try {
String rule = "file: every 1s \n | length > 10 | cachefile";
FileOutputStream os = new FileOutputStream(ruleFile);
os.write(rule.getBytes());
os.close();
SmartAdmin client = new SmartAdmin(conf);
String[] args = new String[] { "submitrule", ruleFile };
SmartShell.main(args);
Thread.sleep(2000);
List<RuleInfo> infos = client.listRulesInfo();
Assert.assertTrue(infos.size() == 1);
Thread.sleep(1500);
List<RuleInfo> infos2 = client.listRulesInfo();
long diff = infos2.get(0).getNumChecked() - infos.get(0).getNumChecked();
Assert.assertTrue(diff >= 1);
} finally {
File f = new File(ruleFile);
if (f.exists()) {
f.deleteOnExit();
}
}
}
use of org.smartdata.common.rule.RuleInfo in project SSM by Intel-bigdata.
the class TestRuleManager method testMultiThreadUpdate.
@Test
public void testMultiThreadUpdate() throws Exception {
String rule = "file: every 1s \n | length > 10 | cachefile";
long now = System.currentTimeMillis();
long rid = ruleManager.submitRule(rule, RuleState.DISABLED);
ruleManager.updateRuleInfo(rid, null, now, 1, 1);
long start = System.currentTimeMillis();
Thread[] threads = new Thread[] { new Thread(new RuleInfoUpdater(rid, 3)), new Thread(new RuleInfoUpdater(rid, 7)), new Thread(new RuleInfoUpdater(rid, 11)), new Thread(new RuleInfoUpdater(rid, 17)) };
for (Thread t : threads) {
t.start();
}
for (Thread t : threads) {
t.join();
}
long end = System.currentTimeMillis();
System.out.println("Time used = " + (end - start) + " ms");
RuleInfo res = ruleManager.getRuleInfo(rid);
System.out.println(res);
}
Aggregations