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);
}
}
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);
}
}
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;
}
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);
}
}
}
}
}
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;
}
}
Aggregations