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);
}
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) {
}
}
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--;
}
}
}
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--;
}
}
}
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--;
}
}
}
Aggregations