Search in sources :

Example 11 with AgentException

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

the class DistributedLoadExecutor method serializeObject.

/**
     * Serialize the threading pattern so we can pass it over the web service
     *
     * @param object the object to serialize
     * @return serialized pattern
     * @throws AgentException on error while serializing
     */
private final byte[] serializeObject(Object object) throws AgentException {
    try {
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
        objectOutStream.writeObject(object);
        return byteOutStream.toByteArray();
    } catch (IOException ioe) {
        throw new AgentException("Could not serialize input arguments for object " + ((object != null) ? object.toString() : object), ioe);
    }
}
Also used : AgentException(com.axway.ats.agent.core.exceptions.AgentException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 12 with AgentException

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

the class DistributedLoadExecutor method getActionExecutionResults.

/**
     * Get the action execution results for a given queue on a given agent
     */
@SuppressWarnings("unchecked")
public List<ActionExecutionStatistic> getActionExecutionResults(String atsAgent, String queueName) throws AgentException {
    // get the client instance
    AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
    try {
        ByteArrayInputStream byteInStream = new ByteArrayInputStream(agentServicePort.getActionExecutionResults(queueName));
        ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
        return (List<ActionExecutionStatistic>) objectInStream.readObject();
    } catch (Exception ioe) {
        // log hint for further serialization issue investigation
        log.error(ioe);
        throw new AgentException(ioe);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) ByteArrayInputStream(java.io.ByteArrayInputStream) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ArrayList(java.util.ArrayList) List(java.util.List) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) ObjectInputStream(java.io.ObjectInputStream)

Example 13 with AgentException

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

the class AbstractClientExecutor method retrieveQueueId.

/**
     * Start performance queue in the database and retrieve its ID
     *
     * @return the started queue ID
     * @throws AgentException 
     */
public int retrieveQueueId(int sequence, String hostsList) throws AgentException {
    int queueId;
    try {
        if (dbAccess == null) {
            dbAccess = new DbAccessFactory().getNewDbWriteAccessObject();
        }
        queueId = dbAccess.startLoadQueue(queueName, sequence, hostsList, threadingPattern.getPatternDescription(), threadingPattern.getThreadCount(), LOCAL_MACHINE, Calendar.getInstance().getTimeInMillis(), ActiveDbAppender.getCurrentInstance().getTestCaseId(), true);
        log.rememberLoadQueueState(queueName, queueId, threadingPattern.getPatternDescription(), threadingPattern.getThreadCount());
    } catch (DatabaseAccessException e) {
        if (ActiveDbAppender.getCurrentInstance() == null) {
            // The log4j DB appender is not attached
            // We assume the user is running a performance test without DB logging
            log.warn("Unable to register a performance queue with name '" + queueName + "' in the loggging database." + " This means the results of running this queue will not be registered in the log DB." + " Check your DB configuration in order to fix this problem.");
            // Return this invalid value will not cause an error on the Test Executor side
            // We also know there will be no error on agent's side as our DB appender will not be present there
            queueId = -1;
        } else {
            throw new AgentException("Unable to register a performance queue with name '" + queueName + "' in the loggging database. This queue will not run at all.", e);
        }
    }
    return queueId;
}
Also used : DbAccessFactory(com.axway.ats.log.autodb.DbAccessFactory) AgentException(com.axway.ats.agent.core.exceptions.AgentException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Example 14 with AgentException

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

the class TestcaseStateListener method onConfigureAtsAgents.

/**
     * This event is send right before running a regular action or starting
     * an action queue.
     *
     * It is also expected to be send between onTestStart and onTestEnd events.
     */
@Override
public void onConfigureAtsAgents(List<String> atsAgents) throws Exception {
    if (configuredAgents == null) {
        // No TestCase is started so we won't configure the remote agents
        return;
    }
    for (String atsAgent : atsAgents) {
        // configure only not configured agents
        if (!configuredAgents.contains(atsAgent)) {
            // We will try to prevent that adding a 'unique' prefix
            synchronized (("ATS_STRING_LOCK-" + atsAgent).intern()) {
                if (!configuredAgents.contains(atsAgent)) {
                    // Pass the logging configuration to the remote agent
                    RemoteLoggingConfigurator remoteLoggingConfigurator = new RemoteLoggingConfigurator(atsAgent);
                    new RemoteConfigurationManager().pushConfiguration(atsAgent, remoteLoggingConfigurator);
                    try {
                        AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
                        agentServicePort.onTestStart(getCurrentTestCaseState());
                    } catch (AgentException_Exception ae) {
                        throw new AgentException(ae.getMessage());
                    }
                    configuredAgents.add(atsAgent);
                }
            }
        }
    }
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) AgentService(com.axway.ats.agent.webapp.client.AgentService) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)

Example 15 with AgentException

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

the class AgentWsImpl method getActionExecutionResults.

/**
     * Queue has already finished and the Test Executor is asking for the
     * queue execution results.
     *
     * There is theoretical chance to be called by more than one thread on Test Executor side,
     * when more than one queue is started in non-blocking mode. That's why it is synchronized
     *
     * @param queueName
     * @return
     * @throws AgentException
     */
@WebMethod
public synchronized byte[] getActionExecutionResults(@WebParam(name = "name") String queueName) throws AgentException {
    try {
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
        objectOutStream.writeObject(QueueExecutionStatistics.getInstance().getActionExecutionResults(queueName));
        return byteOutStream.toByteArray();
    } catch (Exception e) {
        handleExceptions(e);
        // always throw but the compiler is not aware of this
        return null;
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) 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) 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