Search in sources :

Example 11 with CommandInfo

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();
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) ResultSet(java.sql.ResultSet)

Example 12 with CommandInfo

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;
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) LinkedList(java.util.LinkedList)

Example 13 with CommandInfo

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);
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo)

Example 14 with CommandInfo

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

Aggregations

CommandInfo (org.smartdata.common.command.CommandInfo)14 IOException (java.io.IOException)3 Test (org.junit.Test)3 ServiceException (com.google.protobuf.ServiceException)2 File (java.io.File)2 Connection (java.sql.Connection)2 ArrayList (java.util.ArrayList)2 CommandInfoProto (org.smartdata.common.protocol.AdminServerProto.CommandInfoProto)2 DBAdapter (org.smartdata.server.metastore.DBAdapter)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 CommandState (org.smartdata.common.CommandState)1 ListCommandInfoRequestProto (org.smartdata.common.protocol.AdminServerProto.ListCommandInfoRequestProto)1