use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.
the class DistributedLoadExecutor method waitUntilQueueFinish.
@Override
public void waitUntilQueueFinish() throws AgentException {
try {
for (String host : atsAgents) {
AgentService agentServicePort = AgentServicePool.getInstance().getClient(host);
log.info("Waiting until action queue '" + queueName + "' finish its execution on agent '" + host + "'");
//wait until finished on this host
agentServicePort.waitUntilQueueFinish(queueName);
log.info("Action queue '" + queueName + "' finished on agent '" + host + "'");
}
} catch (AgentException_Exception ae) {
throw new AgentException(ae.getMessage());
} catch (InternalComponentException_Exception ice) {
throw new AgentException(ice.getMessage() + ", check server log for stack trace");
} catch (Exception e) {
throw new AgentException(e.getMessage(), e);
}
}
use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.
the class RemoteExecutor method executeAction.
@Override
public Object executeAction(ActionRequest actionRequest) throws AgentException {
String actionName = actionRequest.getActionName();
String componentName = actionRequest.getComponentName();
Object[] arguments = actionRequest.getArguments();
Object result = null;
List<ArgumentWrapper> wrappedArguments = new ArrayList<ArgumentWrapper>();
try {
//a byte stream
for (Object argument : arguments) {
ArgumentWrapper argWrapper = new ArgumentWrapper();
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
objectOutStream.writeObject(argument);
argWrapper.setArgumentValue(byteOutStream.toByteArray());
wrappedArguments.add(argWrapper);
}
} catch (IOException ioe) {
throw new AgentException("Could not serialize input arguments", ioe);
}
//get the client
AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
try {
//FIXME: swap with ActionWrapper
byte[] resultAsBytes = agentServicePort.executeAction(componentName, actionName, wrappedArguments);
//the result is returned as serialized stream
//so we need to deserialize it
ByteArrayInputStream byteInStream = new ByteArrayInputStream(resultAsBytes);
ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
result = objectInStream.readObject();
} catch (IOException ioe) {
throw new AgentException("Could not deserialize returned result from agent at " + atsAgent, ioe);
} catch (AgentException_Exception ae) {
throw new AgentException("Error while executing action on agent at " + atsAgent + ". Exception message: " + ae.getMessage());
} catch (InternalComponentException_Exception ice) {
//we need to get internal component exception info from the soap fault
InternalComponentException faultInfo = ice.getFaultInfo();
//then construct and throw a real InternalComponentException (not the JAXB mapping type above)
throw new com.axway.ats.agent.core.exceptions.InternalComponentException(faultInfo.getComponentName(), faultInfo.getActionName(), faultInfo.getExceptionMessage() + "\n[" + HostUtils.getLocalHostIP() + " stacktrace]", atsAgent);
} catch (Exception e) {
throw new AgentException(e.getMessage(), e);
}
return result;
}
use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.
the class RemoteExecutor method waitUntilQueueFinish.
@Override
public void waitUntilQueueFinish() throws AgentException {
/*
* In real environment, this method is most likely never used
* as this remote client is used for running a single action, so
* no performance queues are available.
*
* TODO: maybe we can safely throw some error here to say that
* it is not expected to call this method.
* Or we can implement an empty body here or in the abstract parent.
*/
//get the client
AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
try {
log.info("Waiting until all queues on host '" + atsAgent + "' finish execution");
agentServicePort.waitUntilAllQueuesFinish();
} catch (AgentException_Exception ae) {
throw new AgentException(ae.getMessage());
} catch (InternalComponentException_Exception ice) {
throw new AgentException(ice.getMessage() + ", check server log for stack trace");
} catch (Exception e) {
throw new AgentException(e.getMessage(), e);
}
}
use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.
the class DistributedLoadExecutor method startSynchedIterations.
private void startSynchedIterations() {
log.info("Start executing action queue '" + queueName + "' with synchronized iterations on " + atsAgents.toString());
try {
for (String host : atsAgents) {
AgentService agentServicePort = AgentServicePool.getInstance().getClient(host);
agentServicePort.startQueue(queueName);
}
} catch (Exception e) {
String msg = "Error running action queue '" + queueName + "'";
log.error(msg, e);
throw new RuntimeException(msg, e);
}
}
use of com.axway.ats.agent.webapp.client.AgentService 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);
}
}
Aggregations