use of org.smartdata.model.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 | cache";
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, 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);
}
use of org.smartdata.model.RuleInfo in project SSM by Intel-bigdata.
the class TestGetRuleInfo method testGetSingleRuleInfo.
@Test
public void testGetSingleRuleInfo() throws Exception {
waitTillSSMExitSafeMode();
String rule = "file: every 1s \n | length > 10 | cache";
SmartAdmin client = new SmartAdmin(smartContext.getConf());
long ruleId = client.submitRule(rule, RuleState.ACTIVE);
RuleInfo info1 = client.getRuleInfo(ruleId);
System.out.println(info1);
Assert.assertTrue(info1.getRuleText().equals(rule));
RuleInfo infoTemp = info1;
for (int i = 0; i < 3; i++) {
Thread.sleep(1000);
infoTemp = client.getRuleInfo(ruleId);
System.out.println(infoTemp);
}
Assert.assertTrue(infoTemp.getNumChecked() >= info1.getNumChecked() + 2);
long fakeRuleId = 10999999999L;
try {
client.getRuleInfo(fakeRuleId);
Assert.fail("Should raise an exception when using a invalid rule id");
} catch (IOException e) {
}
}
use of org.smartdata.model.RuleInfo in project SSM by Intel-bigdata.
the class TestGetRuleInfo method testMultiRules.
@Test
public void testMultiRules() throws Exception {
waitTillSSMExitSafeMode();
String rule = "file: every 1s \n | length > 10 | cache";
SmartAdmin client = new SmartAdmin(smartContext.getConf());
int nRules = 10;
for (int i = 0; i < nRules; i++) {
client.submitRule(rule, RuleState.ACTIVE);
}
List<RuleInfo> ruleInfos = client.listRulesInfo();
for (RuleInfo info : ruleInfos) {
System.out.println(info);
}
Assert.assertTrue(ruleInfos.size() == nRules);
}
Aggregations