Search in sources :

Example 26 with RuleInfo

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);
}
Also used : RuleInfo(org.smartdata.model.RuleInfo) Test(org.junit.Test)

Example 27 with RuleInfo

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) {
    }
}
Also used : SmartAdmin(org.smartdata.admin.SmartAdmin) IOException(java.io.IOException) RuleInfo(org.smartdata.model.RuleInfo) Test(org.junit.Test)

Example 28 with RuleInfo

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);
}
Also used : SmartAdmin(org.smartdata.admin.SmartAdmin) RuleInfo(org.smartdata.model.RuleInfo) Test(org.junit.Test)

Aggregations

RuleInfo (org.smartdata.model.RuleInfo)28 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)6 DetailedRuleInfo (org.smartdata.model.DetailedRuleInfo)6 IOException (java.io.IOException)5 SmartAdmin (org.smartdata.admin.SmartAdmin)4 RuleInfoRepo (org.smartdata.server.engine.rule.RuleInfoRepo)4 CmdletInfo (org.smartdata.model.CmdletInfo)3 ServiceException (com.google.protobuf.ServiceException)2 MetaStoreException (org.smartdata.metastore.MetaStoreException)2 ActionInfo (org.smartdata.model.ActionInfo)2 BackUpInfo (org.smartdata.model.BackUpInfo)2 FileInfo (org.smartdata.model.FileInfo)2 TimeBasedScheduleInfo (org.smartdata.model.rule.TimeBasedScheduleInfo)2 TranslateResult (org.smartdata.model.rule.TranslateResult)2 RuleInfoProto (org.smartdata.protocol.AdminServerProto.RuleInfoProto)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Properties (java.util.Properties)1