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