use of org.smartdata.model.ActionDescriptor in project SSM by Intel-bigdata.
the class ServerProtocolsServerSideTranslator method listActionsSupported.
@Override
public ListActionsSupportedResponseProto listActionsSupported(RpcController controller, ListActionsSupportedRequestProto req) throws ServiceException {
try {
List<ActionDescriptor> adList = server.listActionsSupported();
List<ActionDescriptorProto> prolist = new ArrayList<>();
for (ActionDescriptor a : adList) {
prolist.add(ProtoBufferHelper.convert(a));
}
return ListActionsSupportedResponseProto.newBuilder().addAllActDesList(prolist).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of org.smartdata.model.ActionDescriptor in project SSM by Intel-bigdata.
the class AdminProtocolClientSideTranslator method listActionsSupported.
@Override
public List<ActionDescriptor> listActionsSupported() throws IOException {
ListActionsSupportedRequestProto req = ListActionsSupportedRequestProto.newBuilder().build();
try {
List<ActionDescriptorProto> prolist = rpcProxy.listActionsSupported(null, req).getActDesListList();
List<ActionDescriptor> list = new ArrayList<>();
for (ActionDescriptorProto a : prolist) {
list.add(ProtoBufferHelper.convert(a));
}
return list;
} catch (ServiceException e) {
throw ProtoBufferHelper.getRemoteException(e);
}
}
use of org.smartdata.model.ActionDescriptor in project SSM by Intel-bigdata.
the class TestSmartAdmin method test.
@Test
public void test() throws Exception {
waitTillSSMExitSafeMode();
SmartAdmin admin = null;
try {
admin = new SmartAdmin(smartContext.getConf());
// test listRulesInfo and submitRule
List<RuleInfo> ruleInfos = admin.listRulesInfo();
int ruleCounts0 = ruleInfos.size();
long ruleId = admin.submitRule("file: every 5s | path matches \"/foo*\"| cache", RuleState.DRYRUN);
ruleInfos = admin.listRulesInfo();
int ruleCounts1 = ruleInfos.size();
assertEquals(1, ruleCounts1 - ruleCounts0);
// test checkRule
// if success ,no Exception throw
admin.checkRule("file: every 5s | path matches \"/foo*\"| cache");
boolean caughtException = false;
try {
admin.checkRule("file.path");
} catch (IOException e) {
caughtException = true;
}
assertTrue(caughtException);
// test getRuleInfo
RuleInfo ruleInfo = admin.getRuleInfo(ruleId);
assertNotEquals(null, ruleInfo);
// test disableRule
admin.disableRule(ruleId, true);
assertEquals(RuleState.DISABLED, admin.getRuleInfo(ruleId).getState());
// test activateRule
admin.activateRule(ruleId);
assertEquals(RuleState.ACTIVE, admin.getRuleInfo(ruleId).getState());
// test deleteRule
admin.deleteRule(ruleId, true);
assertEquals(RuleState.DELETED, admin.getRuleInfo(ruleId).getState());
// test cmdletInfo
long id = admin.submitCmdlet("cache -file /foo*");
CmdletInfo cmdletInfo = admin.getCmdletInfo(id);
assertTrue("cache -file /foo*".equals(cmdletInfo.getParameters()));
// test actioninfo
List<Long> aidlist = cmdletInfo.getAids();
assertNotEquals(0, aidlist.size());
ActionInfo actionInfo = admin.getActionInfo(aidlist.get(0));
assertEquals(id, actionInfo.getCmdletId());
// test listActionInfoOfLastActions
admin.listActionInfoOfLastActions(2);
List<ActionDescriptor> actions = admin.listActionsSupported();
assertTrue(actions.size() > 0);
// test client close
admin.close();
try {
admin.getRuleInfo(ruleId);
Assert.fail("Should fail because admin has closed.");
} catch (IOException e) {
}
admin = null;
} finally {
if (admin != null) {
admin.close();
}
}
}
Aggregations