Search in sources :

Example 1 with SmartAdmin

use of org.smartdata.admin.SmartAdmin 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 | cachefile";
    SmartAdmin client = new SmartAdmin(conf);
    int nRules = 100;
    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.common.rule.RuleInfo) Test(org.junit.Test)

Example 2 with SmartAdmin

use of org.smartdata.admin.SmartAdmin 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 | cachefile";
    SmartAdmin client = new SmartAdmin(conf);
    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.common.rule.RuleInfo) Test(org.junit.Test)

Example 3 with SmartAdmin

use of org.smartdata.admin.SmartAdmin in project SSM by Intel-bigdata.

the class TestEmptyMiniSmartCluster method waitTillSSMExitSafeMode.

public void waitTillSSMExitSafeMode() throws Exception {
    SmartAdmin client = new SmartAdmin(conf);
    long start = System.currentTimeMillis();
    int retry = 5;
    while (true) {
        try {
            SmartServiceState state = client.getServiceState();
            if (state != SmartServiceState.SAFEMODE) {
                break;
            }
            int secs = (int) (System.currentTimeMillis() - start) / 1000;
            System.out.println("Waited for " + secs + " seconds ...");
            Thread.sleep(1000);
        } catch (Exception e) {
            if (retry <= 0) {
                throw e;
            }
            retry--;
        }
    }
}
Also used : SmartAdmin(org.smartdata.admin.SmartAdmin) SmartServiceState(org.smartdata.common.SmartServiceState)

Example 4 with SmartAdmin

use of org.smartdata.admin.SmartAdmin in project SSM by Intel-bigdata.

the class IntegrationSmartServer method waitTillSSMExitSafeMode.

private void waitTillSSMExitSafeMode() throws Exception {
    SmartAdmin client = new SmartAdmin(conf);
    long start = System.currentTimeMillis();
    int retry = 5;
    while (true) {
        try {
            SmartServiceState state = client.getServiceState();
            if (state != SmartServiceState.SAFEMODE) {
                break;
            }
            int secs = (int) (System.currentTimeMillis() - start) / 1000;
            System.out.println("Waited for " + secs + " seconds ...");
            Thread.sleep(1000);
        } catch (Exception e) {
            if (retry <= 0) {
                throw e;
            }
            retry--;
        }
    }
}
Also used : SmartAdmin(org.smartdata.admin.SmartAdmin) SmartServiceState(org.smartdata.SmartServiceState)

Example 5 with SmartAdmin

use of org.smartdata.admin.SmartAdmin in project SSM by Intel-bigdata.

the class MiniSmartClusterHarness method waitTillSSMExitSafeMode.

public void waitTillSSMExitSafeMode() throws Exception {
    SmartAdmin client = new SmartAdmin(smartContext.getConf());
    long start = System.currentTimeMillis();
    int retry = 5;
    while (true) {
        try {
            SmartServiceState state = client.getServiceState();
            if (state != SmartServiceState.SAFEMODE) {
                break;
            }
            int secs = (int) (System.currentTimeMillis() - start) / 1000;
            System.out.println("Waited for " + secs + " seconds ...");
            Thread.sleep(1000);
        } catch (Exception e) {
            if (retry <= 0) {
                throw e;
            }
            retry--;
        }
    }
}
Also used : SmartAdmin(org.smartdata.admin.SmartAdmin) SmartServiceState(org.smartdata.SmartServiceState) IOException(java.io.IOException)

Aggregations

SmartAdmin (org.smartdata.admin.SmartAdmin)19 Test (org.junit.Test)15 IOException (java.io.IOException)7 ActionInfo (org.smartdata.model.ActionInfo)5 RuleInfo (org.smartdata.model.RuleInfo)4 Path (org.apache.hadoop.fs.Path)3 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)3 RuleInfo (org.smartdata.common.rule.RuleInfo)3 MetaStore (org.smartdata.metastore.MetaStore)3 SmartServiceState (org.smartdata.SmartServiceState)2 CmdletInfo (org.smartdata.model.CmdletInfo)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 Configuration (org.apache.hadoop.conf.Configuration)1 SmartServiceState (org.smartdata.common.SmartServiceState)1 SmartConf (org.smartdata.conf.SmartConf)1 ActionDescriptor (org.smartdata.model.ActionDescriptor)1 S3FileState (org.smartdata.model.S3FileState)1