use of org.smartdata.common.command.CommandInfo in project SSM by Intel-bigdata.
the class DBAdapter method getCommands.
private List<CommandInfo> getCommands(String sql) throws SQLException {
QueryHelper queryHelper = new QueryHelper(sql);
try {
ResultSet result = queryHelper.executeQuery();
List<CommandInfo> ret = convertCommandsTableItem(result);
return ret;
} finally {
queryHelper.close();
}
}
use of org.smartdata.common.command.CommandInfo in project SSM by Intel-bigdata.
the class DBAdapter method convertCommandsTableItem.
private List<CommandInfo> convertCommandsTableItem(ResultSet resultSet) throws SQLException {
List<CommandInfo> ret = new LinkedList<>();
if (resultSet == null) {
return ret;
}
while (resultSet.next()) {
CommandInfo commands = new CommandInfo(resultSet.getLong("cid"), resultSet.getLong("rid"), ActionType.fromValue((int) resultSet.getByte("action_id")), CommandState.fromValue((int) resultSet.getByte("state")), resultSet.getString("parameters"), resultSet.getLong("generate_time"), resultSet.getLong("state_changed_time"));
ret.add(commands);
}
return ret;
}
use of org.smartdata.common.command.CommandInfo in project SSM by Intel-bigdata.
the class CommandExecutor method activateCommand.
public void activateCommand(long cid) throws IOException {
if (inCache(cid)) {
return;
}
if (inUpdateCache(cid)) {
return;
}
CommandInfo cmdinfo = getCommandInfo(cid);
if (cmdinfo == null || cmdinfo.getState() == CommandState.DONE) {
return;
}
LOG.info("Activate Command {}", cid);
cmdinfo.setState(CommandState.PENDING);
addToPending(cmdinfo);
}
use of org.smartdata.common.command.CommandInfo in project SSM by Intel-bigdata.
the class TestCommandExecutor method testActivateDisableCommand.
@Test
public void testActivateDisableCommand() throws Exception {
waitTillSSMExitSafeMode();
generateTestFiles();
generateTestCases();
// Activate 1
ssm.getCommandExecutor().activateCommand(1);
Assert.assertTrue(ssm.getCommandExecutor().inCache(1));
// Disable 1
CommandInfo cmdinfo = ssm.getCommandExecutor().getCommandInfo(1);
if (cmdinfo.getState() != CommandState.DONE) {
ssm.getCommandExecutor().disableCommand(1);
Assert.assertTrue(cmdinfo.getState() == CommandState.DISABLED);
}
}
Aggregations