Search in sources :

Example 6 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 7 with Action

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

the class InternalFileSystemSnapshot method compare.

@Action
public void compare(@Parameter(name = "thisInternalProcessId") String thisInternalProcessId, @Parameter(name = "thatInternalProcessId") String thatInternalProcessId) {
    LocalFileSystemSnapshot thisLocalFileSystemSnapshot = (LocalFileSystemSnapshot) dataRepo.getObject(OBJECT_KEY_PREFIX + thisInternalProcessId);
    LocalFileSystemSnapshot thatLocalFileSystemSnapshot = (LocalFileSystemSnapshot) dataRepo.getObject(OBJECT_KEY_PREFIX + thatInternalProcessId);
    thisLocalFileSystemSnapshot.compare(thatLocalFileSystemSnapshot);
}
Also used : LocalFileSystemSnapshot(com.axway.ats.core.filesystem.snapshot.LocalFileSystemSnapshot) Action(com.axway.ats.agent.core.model.Action) CallerRelatedAction(com.axway.ats.agent.core.action.CallerRelatedAction)

Example 8 with Action

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

the class InternalProcessOperations method killProcessAndItsChildren.

@Action(name = "Internal Process Operations kill Process And Its Children")
public void killProcessAndItsChildren(@Parameter(name = "internalProcessId") String internalProcessId) {
    LocalProcessExecutor processExecutor = (LocalProcessExecutor) dataRepo.getObject(OBJECT_KEY_PREFIX + internalProcessId);
    processExecutor.killAll();
}
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 9 with Action

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

the class ActionClassGenerator method generateStub.

private String generateStub(String componentName, Class<?> actionClass, String targetActionClassPackage, String originalTargetPackage, Map<String, String> actionJavadocMap) {
    try {
        log.info("Generating stub for action class '" + actionClass.getCanonicalName() + "'");
        //first we need to generate the method definitions
        StringBuilder methodsDefinition = new StringBuilder();
        StringBuilder publicConstants = new StringBuilder();
        Method[] actionClassMethods = actionClass.getMethods();
        for (Method actionClassMethod : actionClassMethods) {
            if (isAnActionClass(actionClassMethod)) {
                Action actionAnnotation = actionClassMethod.getAnnotation(Action.class);
                TemplateAction templateActionAnnotation = actionClassMethod.getAnnotation(TemplateAction.class);
                String actionName;
                if (actionAnnotation != null) {
                    actionName = actionAnnotation.name();
                } else {
                    actionName = templateActionAnnotation.name();
                }
                // if the 'name' attribute is empty, generate an action method name
                if (StringUtils.isNullOrEmpty(actionName)) {
                    actionName = ActionMethod.buildActionMethodName(actionClassMethod);
                }
                // check if this is a transfer action and it has the necessary return type
                if (actionAnnotation != null && actionAnnotation.transferUnit().length() > 0 && actionClassMethod.getReturnType() != Long.class) {
                    throw new BuildException("Action '" + actionName + "' has a declared transfer unit, but the return type is not Long");
                }
                String actionJavaDoc = actionJavadocMap.get(actionName);
                //first append the action javadoc (if any)
                if (actionJavaDoc != null) {
                    methodsDefinition.append(actionJavaDoc);
                }
                //then process the method body and append it
                String actionDefinition = generateActionDefinition(actionName, actionClassMethod);
                methodsDefinition.append(actionDefinition);
                //get any enum constants
                publicConstants.append(generateEnumConstants(actionClassMethod));
            }
        }
        //generate the public constants
        publicConstants.append(generateConstantsDefinition(actionClass));
        ClassTemplateProcessor classProcessor;
        if (customTemplates.containsKey(actionClass.getName())) {
            //use the custom template supplied
            classProcessor = new ClassTemplateProcessor(new File(customTemplates.get(actionClass.getName())), originalSourcePackage, originalTargetPackage, targetActionClassPackage, actionClass, componentName, methodsDefinition.toString(), publicConstants.toString());
        } else {
            //use default template
            classProcessor = new ClassTemplateProcessor(originalSourcePackage, originalTargetPackage, targetActionClassPackage, actionClass, componentName, methodsDefinition.toString(), publicConstants.toString());
        }
        return classProcessor.processTemplate();
    } catch (Exception e) {
        throw new BuildException(e);
    }
}
Also used : Action(com.axway.ats.agent.core.model.Action) TemplateAction(com.axway.ats.agent.core.model.TemplateAction) TemplateAction(com.axway.ats.agent.core.model.TemplateAction) Method(java.lang.reflect.Method) ActionMethod(com.axway.ats.agent.core.action.ActionMethod) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 10 with Action

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

the class InternalProcessOperations method appendToEnvVariable.

@Action(name = "Internal Process Operations append To Env Variable")
public void appendToEnvVariable(@Parameter(name = "internalProcessId") String internalProcessId, @Parameter(name = "variableName") String variableName, @Parameter(name = "variableValueToAppend") String variableValueToAppend) {
    LocalProcessExecutor processExecutor = (LocalProcessExecutor) dataRepo.getObject(OBJECT_KEY_PREFIX + internalProcessId);
    processExecutor.appendToEnvVariable(variableName, variableValueToAppend);
}
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)

Aggregations

Action (com.axway.ats.agent.core.model.Action)11 CallerRelatedAction (com.axway.ats.agent.core.action.CallerRelatedAction)7 LocalProcessExecutor (com.axway.ats.core.process.LocalProcessExecutor)5 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 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 HashMap (java.util.HashMap)1 List (java.util.List)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1