Search in sources :

Example 21 with AgentException

use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.

the class SystemMonitor method stopMonitoringProcessOnAgent.

private void stopMonitoringProcessOnAgent(String monitoredAgent) throws MonitoringException {
    try {
        log.debug("Stopping system monitoring on " + monitoredAgent + " agent");
        new AgentMonitoringClient(monitoredAgent).stopMonitoring();
        log.debug("Successfully stopped monitoring " + monitoredAgent + " agent");
    } catch (AgentException e) {
        throw new MonitoringException("Could not stop monitoring " + monitoredAgent + " agent", e);
    }
}
Also used : AgentMonitoringClient(com.axway.ats.agent.webapp.client.AgentMonitoringClient) AgentException(com.axway.ats.agent.core.exceptions.AgentException) MonitoringException(com.axway.ats.monitoring.model.exceptions.MonitoringException)

Example 22 with AgentException

use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.

the class ProcessExecutor method killExternalProcess.

/**
     * Killing external process(such not started by us) on a remote host. <br/>
     * The process is found by a token which is contained in the start command.
     * No regex supported.
     *
     * @param atsAgent the address of the remote ATS agent which will run the kill command
     * @param startCommandSnippet the token to search for in the process start command.
     * The minimum allowed length is 2 characters
     * @return the number of killed processes
     */
@PublicAtsApi
public static int killExternalProcess(@Validate(name = "atsAgent", type = ValidationType.STRING_SERVER_WITH_PORT) String atsAgent, @Validate(name = "startCommandSnippet", type = ValidationType.STRING_NOT_EMPTY) String startCommandSnippet) {
    // validate input parameters
    atsAgent = HostUtils.getAtsAgentIpAndPort(atsAgent);
    new Validator().validateMethodParameters(new Object[] { atsAgent, startCommandSnippet });
    try {
        return new InternalProcessOperations(atsAgent).killExternalProcess(startCommandSnippet);
    } catch (AgentException e) {
        throw new ProcessExecutorException(e);
    }
}
Also used : InternalProcessOperations(com.axway.ats.agent.components.system.operations.clients.InternalProcessOperations) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ProcessExecutorException(com.axway.ats.common.process.ProcessExecutorException) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 23 with AgentException

use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.

the class RemoteSystemOperations method createScreenshot.

@Override
public String createScreenshot(String filePath) {
    try {
        String remoteFilePath = null;
        int extIndex = filePath.lastIndexOf('.');
        if (extIndex > 0) {
            remoteFilePath = filePath.substring(extIndex);
        }
        remoteFilePath = this.remoteSystemOperations.createScreenshot(remoteFilePath);
        new RemoteFileSystemOperations(atsAgent).copyFileFrom(remoteFilePath, filePath, true);
    } catch (AgentException e) {
        throw new SystemOperationException("Could not create screenshot on agent: " + atsAgent, e);
    }
    return filePath;
}
Also used : AgentException(com.axway.ats.agent.core.exceptions.AgentException) SystemOperationException(com.axway.ats.common.system.SystemOperationException) RemoteFileSystemOperations(com.axway.ats.action.filesystem.RemoteFileSystemOperations)

Example 24 with AgentException

use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.

the class AgentWsContextListener method contextInitialized.

/*
     * (non-Javadoc)
     *
     * @see
     * javax.servlet.ServletContextListener#contextInitialized(javax.servlet
     * .ServletContextEvent)
     */
@Override
public void contextInitialized(ServletContextEvent servletEvent) {
    ServletContext servletContext = servletEvent.getServletContext();
    servletContext.log("Servlet context initialized event is received. Starting registering configurators");
    try {
        new ClasspathUtils().logProblematicJars();
    } catch (RuntimeException e) {
        log.warn("Error caught while trying to get all JARs in classpath", e);
    // do not rethrow exception as this will stop deployment on incompliant servers like JBoss
    }
    // create the default web service configurator
    String pathToConfigFile = servletContext.getRealPath("/WEB-INF");
    AgentConfigurator defaultConfigurator = new AgentConfigurator(pathToConfigFile);
    TemplateActionsConfigurator templateActionsConfigurator = new TemplateActionsConfigurator(pathToConfigFile);
    List<Configurator> configurators = new ArrayList<Configurator>();
    configurators.add(defaultConfigurator);
    configurators.add(templateActionsConfigurator);
    log.info("Initializing ATS Agent web service, start component registration");
    try {
        MainComponentLoader.getInstance().initialize(configurators);
    } catch (AgentException ae) {
        throw new RuntimeException("Unable to initialize Agent component loader", ae);
    }
}
Also used : Configurator(com.axway.ats.agent.core.configuration.Configurator) AgentConfigurator(com.axway.ats.agent.core.configuration.AgentConfigurator) TemplateActionsConfigurator(com.axway.ats.agent.core.configuration.TemplateActionsConfigurator) AgentException(com.axway.ats.agent.core.exceptions.AgentException) TemplateActionsConfigurator(com.axway.ats.agent.core.configuration.TemplateActionsConfigurator) ArrayList(java.util.ArrayList) ServletContext(javax.servlet.ServletContext) ClasspathUtils(com.axway.ats.core.utils.ClasspathUtils) AgentConfigurator(com.axway.ats.agent.core.configuration.AgentConfigurator)

Example 25 with AgentException

use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.

the class AgentWsImpl method scheduleActionsInMultipleThreads.

/**
     * Schedule a set of actions (queue) in multiple threads. The actions
     * will not be executed until a call to startQueue is made
     *
     * @param queueName the name of the action queue
     * @param actions the actions in that queue
     * @param serializedThreadingPattern the serialized threading pattern to be used
     * @param testCaseState the test case state
     * @throws AgentException on error
     * @throws InternalComponentException if an exception is thrown while the actions are executed
     */
@WebMethod
public void scheduleActionsInMultipleThreads(@WebParam(name = "name") String queueName, @WebParam(name = "queueId") int queueId, @WebParam(name = "actions") ActionWrapper[] actions, @WebParam(name = "serializedThreadingPattern") byte[] serializedThreadingPattern, @WebParam(name = "serializedLoaderDataConfig") byte[] serializedLoaderDataConfig, boolean isUseSynchronizedIterations) throws AgentException, InternalComponentException {
    final String caller = getCaller();
    ThreadsPerCaller.registerThread(caller);
    try {
        ArrayList<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
        for (ActionWrapper actionWrapper : actions) {
            List<ArgumentWrapper> args = actionWrapper.getArgs();
            int numArguments = args.size();
            Object[] arguments = new Object[numArguments];
            // unwrap the action arguments
            for (int i = 0; i < numArguments; i++) {
                ArgumentWrapper argWrapper = args.get(i);
                ByteArrayInputStream byteInStream = new ByteArrayInputStream(argWrapper.getArgumentValue());
                ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
                arguments[i] = objectInStream.readObject();
            }
            // construct the action request
            ActionRequest actionRequest = new ActionRequest(actionWrapper.getComponentName(), actionWrapper.getActionName(), arguments);
            actionRequests.add(actionRequest);
        }
        ByteArrayInputStream byteInStream;
        ObjectInputStream objectInStream;
        // de-serialize the threading configuration
        byteInStream = new ByteArrayInputStream(serializedThreadingPattern);
        objectInStream = new ObjectInputStream(byteInStream);
        ThreadingPattern threadingPattern = (ThreadingPattern) objectInStream.readObject();
        // de-serialize the loader data configuration
        byteInStream = new ByteArrayInputStream(serializedLoaderDataConfig);
        objectInStream = new ObjectInputStream(byteInStream);
        LoaderDataConfig loaderDataConfig = (LoaderDataConfig) objectInStream.readObject();
        MultiThreadedActionHandler.getInstance(caller).scheduleActions(caller, queueName, queueId, actionRequests, threadingPattern, loaderDataConfig, isUseSynchronizedIterations);
    } catch (Exception e) {
        handleExceptions(e);
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
}
Also used : ArrayList(java.util.ArrayList) InternalComponentException(com.axway.ats.agent.core.exceptions.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) NoSuchActionException(com.axway.ats.agent.core.exceptions.NoSuchActionException) NoCompatibleMethodFoundException(com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException) NoSuchComponentException(com.axway.ats.agent.core.exceptions.NoSuchComponentException) IOException(java.io.IOException) ActionExecutionException(com.axway.ats.agent.core.exceptions.ActionExecutionException) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) ThreadingPattern(com.axway.ats.agent.core.threading.patterns.ThreadingPattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInputStream(java.io.ObjectInputStream) WebMethod(javax.jws.WebMethod)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)42 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)11 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)9 AgentService (com.axway.ats.agent.webapp.client.AgentService)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ObjectOutputStream (java.io.ObjectOutputStream)7 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)6 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)6 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 MonitoringException (com.axway.ats.monitoring.model.exceptions.MonitoringException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ObjectInputStream (java.io.ObjectInputStream)5 WebMethod (javax.jws.WebMethod)5 DatabaseEnvironmentUnit (com.axway.ats.environment.database.DatabaseEnvironmentUnit)4 File (java.io.File)4