Search in sources :

Example 1 with Action

use of com.axway.ats.agent.core.model.Action in project ats-framework by Axway.

the class InternalSystemMonitoringOperations method initializeMonitoring.

@Action(name = "Internal System Monitoring Operations Initialize Monitoring")
public void initializeMonitoring(@Parameter(name = "readings") List<FullReadingBean> readings, @Parameter(name = "startTimestamp") long startTimestamp, @Parameter(name = "pollInterval") int pollInterval) throws Exception {
    monitoringAgent = new AtsSystemMonitoringAgent(startTimestamp, pollInterval);
    Map<String, List<FullReadingBean>> readingsPerMonitor = new HashMap<String, List<FullReadingBean>>();
    // load all the monitors and initialize them
    for (FullReadingBean reading : readings) {
        List<FullReadingBean> readingsForThisMonitor = readingsPerMonitor.get(reading.getMonitorName());
        if (readingsForThisMonitor == null) {
            readingsForThisMonitor = new ArrayList<FullReadingBean>();
            readingsPerMonitor.put(reading.getMonitorName(), readingsForThisMonitor);
        }
        readingsForThisMonitor.add(reading);
    }
    for (String monitorClassName : readingsPerMonitor.keySet()) {
        initializeMonitor(monitorClassName, readingsPerMonitor.get(monitorClassName), pollInterval);
    }
}
Also used : HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean) AtsSystemMonitoringAgent(com.axway.ats.agent.components.monitoring.model.agents.AtsSystemMonitoringAgent) Action(com.axway.ats.agent.core.model.Action)

Example 2 with Action

use of com.axway.ats.agent.core.model.Action in project ats-framework by Axway.

the class FileTransferActions method connect.

/**
 * Do a connect
 *
 * @param protocol the transfer protocol to use
 * @param port the remote port
 * @param hostname the remote host
 * @param username the user name
 * @param password the user password
 */
@Action
public void connect(@Parameter(name = "protocol") String protocol, @Parameter(name = "port") int port, @Parameter(name = "hostname") String hostname, @Parameter(name = "username") String username, @Parameter(name = "password") String password) {
    // make instance of the transfer client and do a connect
    transferClient = new FileTransferClient(TransferProtocol.valueOf(protocol));
    transferClient.setPort(port);
    transferClient.connect(hostname, username, password);
}
Also used : FileTransferClient(com.axway.ats.action.filetransfer.FileTransferClient) Action(com.axway.ats.agent.core.model.Action)

Example 3 with Action

use of com.axway.ats.agent.core.model.Action in project ats-framework by Axway.

the class InternalProcessOperations method killProcess.

@Action(name = "Internal Process Operations kill Process")
public void killProcess(@Parameter(name = "internalProcessId") String internalProcessId) {
    LocalProcessExecutor processExecutor = (LocalProcessExecutor) dataRepo.getObject(OBJECT_KEY_PREFIX + internalProcessId);
    processExecutor.kill();
}
Also used : LocalProcessExecutor(com.axway.ats.core.process.LocalProcessExecutor) Action(com.axway.ats.agent.core.model.Action) CallerRelatedAction(com.axway.ats.agent.core.action.CallerRelatedAction)

Example 4 with Action

use of com.axway.ats.agent.core.model.Action in project ats-framework by Axway.

the class InternalProcessOperations method startProcess.

/**
 * @param internalProcessId internal process id (the unique id for the current LocalProcessExecutor)
 * @param workDirectory the working directory. If null, the working directory of the current Java process will be used
 * @param standardOutputFile the standard output file name. If null, the standard output will not be sent to a file
 * @param errorOutputFile the error output file name. If null, the error output will not be sent to a file
 * @param logStandardOutput whether to log the standard output
 * @param logErrorOutput whether to log the error output
 * @param waitForCompletion whether to wait for a process completion
 */
@Action(name = "Internal Process Operations start Process")
public void startProcess(@Parameter(name = "internalProcessId") String internalProcessId, @Parameter(name = "workDirectory") String workDirectory, @Parameter(name = "standardOutputFile") String standardOutputFile, @Parameter(name = "errorOutputFile") String errorOutputFile, @Parameter(name = "logStandardOutput") boolean logStandardOutput, @Parameter(name = "logErrorOutput") boolean logErrorOutput, @Parameter(name = "waitForCompletion") boolean waitForCompletion) {
    LocalProcessExecutor processExecutor = (LocalProcessExecutor) dataRepo.getObject(OBJECT_KEY_PREFIX + internalProcessId);
    processExecutor.setWorkDirectory(workDirectory);
    processExecutor.setStandardOutputFile(standardOutputFile);
    processExecutor.setErrorOutputFile(errorOutputFile);
    processExecutor.setLogStandardOutput(logStandardOutput);
    processExecutor.setLogErrorOutput(logErrorOutput);
    processExecutor.execute(waitForCompletion);
}
Also used : LocalProcessExecutor(com.axway.ats.core.process.LocalProcessExecutor) Action(com.axway.ats.agent.core.model.Action) CallerRelatedAction(com.axway.ats.agent.core.action.CallerRelatedAction)

Example 5 with Action

use of com.axway.ats.agent.core.model.Action in project ats-framework by Axway.

the class InternalProcessOperations method getEnvVariables.

@Action(name = "Internal Process Operations get Env Variables")
public Map<String, String> getEnvVariables(@Parameter(name = "internalProcessId") String internalProcessId) {
    LocalProcessExecutor processExecutor = (LocalProcessExecutor) dataRepo.getObject(OBJECT_KEY_PREFIX + internalProcessId);
    // some internal impl, not serializable
    Map<String, String> mapInt = processExecutor.getEnvVariables();
    // clone and serializable
    HashMap<String, String> hMap = new HashMap<>(mapInt);
    return hMap;
}
Also used : HashMap(java.util.HashMap) LocalProcessExecutor(com.axway.ats.core.process.LocalProcessExecutor) Action(com.axway.ats.agent.core.model.Action) CallerRelatedAction(com.axway.ats.agent.core.action.CallerRelatedAction)

Aggregations

Action (com.axway.ats.agent.core.model.Action)13 CallerRelatedAction (com.axway.ats.agent.core.action.CallerRelatedAction)8 LocalProcessExecutor (com.axway.ats.core.process.LocalProcessExecutor)6 ArrayList (java.util.ArrayList)3 ActionMethod (com.axway.ats.agent.core.action.ActionMethod)2 TemplateAction (com.axway.ats.agent.core.model.TemplateAction)2 Method (java.lang.reflect.Method)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 HashMap (java.util.HashMap)2 FileTransferClient (com.axway.ats.action.filetransfer.FileTransferClient)1 AtsSystemMonitoringAgent (com.axway.ats.agent.components.monitoring.model.agents.AtsSystemMonitoringAgent)1 TemplateActionMethod (com.axway.ats.agent.core.action.TemplateActionMethod)1 ActionAlreadyDefinedException (com.axway.ats.agent.core.exceptions.ActionAlreadyDefinedException)1 AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 FullReadingBean (com.axway.ats.common.performance.monitor.beans.FullReadingBean)1 LocalFileSystemSnapshot (com.axway.ats.core.filesystem.snapshot.LocalFileSystemSnapshot)1 File (java.io.File)1 IOException (java.io.IOException)1 List (java.util.List)1