use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class LocalLoadExecutor method executeActions.
@Override
public void executeActions(List<ActionRequest> actionRequests) throws AgentException {
log.info("Start executing action queue '" + queueName + "'." + (threadingPattern.isBlockUntilCompletion() ? " And wait to finish." : ""));
// start queue in the database and retrieve its ID
int queueId = retrieveQueueId(queueSequence, HostUtils.getLocalHostIP());
try {
MultiThreadedActionHandler.getInstance(ThreadsPerCaller.getCaller()).executeActions("LOCAL", queueName, queueId, actionRequests, threadingPattern, loaderDataConfig);
if (threadingPattern.isBlockUntilCompletion()) {
log.endLoadQueue(queueName, LoadQueueResult.PASSED);
log.info("Finished executing action queue '" + queueName + "'");
} else {
// wait in another thread until the queue finish
ImportantThread helpThread = new ImportantThread(new Runnable() {
@Override
public void run() {
try {
MultiThreadedActionHandler.getInstance(ThreadsPerCaller.getCaller()).waitUntilQueueFinish(queueName);
log.endLoadQueue(queueName, LoadQueueResult.PASSED);
log.info("Finished executing action queue '" + queueName + "'");
} catch (NoSuchLoadQueueException e) {
log.error("Error waiting for action queue '" + queueName + "' completion", e);
log.endLoadQueue(queueName, LoadQueueResult.FAILED);
}
}
});
helpThread.setDescription(queueName);
helpThread.start();
log.info("Action queue '" + queueName + "' scheduled for asynchronous execution");
}
} catch (Exception e) {
throw new AgentException(e.getMessage(), e);
}
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class RemoteExecutor method wrapActionRequest.
/**
* Wrap the action request into an ActionWrapper so it is easily
* passed to the web service
*
* @param actionRequest the action request to wrap
* @return the action wrapper
* @throws AgentException on error
*/
protected final ActionWrapper wrapActionRequest(ActionRequest actionRequest) throws AgentException {
Object[] arguments = actionRequest.getArguments();
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);
}
//construct the action wrapper
ActionWrapper actionWrapper = new ActionWrapper();
actionWrapper.setComponentName(actionRequest.getComponentName());
actionWrapper.setActionName(actionRequest.getActionName());
actionWrapper.getArgs().addAll(wrappedArguments);
return actionWrapper;
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class AgentMonitoringClient method getMonitoringResults.
/**
* @return the latest info about the Agent users activity
* @throws AgentException
*/
@SuppressWarnings("unchecked")
public List<MonitorResults> getMonitoringResults() throws AgentException {
// get the client instance
AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
try {
ByteArrayInputStream byteInStream = new ByteArrayInputStream(agentServicePort.getMonitoringResults());
ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
return (List<MonitorResults>) 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 DynamicComponentLoader method loadComponents.
@Override
protected void loadComponents(ComponentRepository componentRepository) throws AgentException {
if (componentsLocation == null || !componentsLocation.isDirectory() || !componentsLocation.exists()) {
throw new AgentException("Components location not set, does not exist or is not a directory");
}
log.debug("Unloading any existing components");
//clear the action map before registering
componentRepository.clear();
//init the class loader for loading the action classes
ClassLoader currentClassLoader = DynamicComponentLoader.class.getClassLoader();
actionClassesClassLoader = new ReversedDelegationClassLoader(new URL[] {}, currentClassLoader);
File[] files = componentsLocation.listFiles();
// java.io.File constructor accepts URIs where ClassLoader requires URLs
List<URI> jarFileURIs = new ArrayList<URI>();
if (files != null) {
//get only the jar files
for (File file : files) {
if (file.getAbsolutePath().endsWith(".jar")) {
try {
// file.toURL() is deprecated and in case with spaces in directories there were errors
URI jarFileURI = file.toURI();
jarFileURIs.add(jarFileURI);
//add the jar file to our custom class loader
//it may not be an Agent component (i.e. no descriptor) but
//an Agent component might depend on it anyway
actionClassesClassLoader.addURL(jarFileURI.toURL());
} catch (MalformedURLException mue) {
log.warn("Malformed URL", mue);
}
}
}
}
for (URI uri : jarFileURIs) {
JarFile jarFile = null;
try {
jarFile = new JarFile(new File(uri));
JarEntry entry = jarFile.getJarEntry(COMPONENT_DESCRIPTOR_NAME);
if (entry != null) {
log.info("Found component library in '" + uri.toURL().getFile() + "', starting registration process");
InputStream descriptorStream = jarFile.getInputStream(entry);
ConfigurationParser configParser = new ConfigurationParser();
try {
configParser.parse(descriptorStream, (new File(uri)).getAbsolutePath());
registerComponent(configParser, componentRepository);
log.info("Successfully registered component library with name '" + configParser.getComponentName() + "'");
} catch (Exception e) {
log.warn("Exception thrown while loading library '" + uri.toURL().getFile() + "', skipping it", e);
continue;
}
}
} catch (IOException ioe) {
try {
log.warn("Could not open library '" + uri.toURL().getFile() + "', skipping it");
} catch (MalformedURLException e) {
log.error(e);
}
} finally {
IoUtils.closeStream(jarFile);
}
}
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class SystemMonitor method initializeSystemMonitoringProcess.
private void initializeSystemMonitoringProcess(String monitoredHost, Set<FullReadingBean> readings) throws MonitoringException {
log.debug("Initializing the system monitoring process on " + monitoredHost);
try {
InternalSystemMonitoringOperations sysMonitoringActions = new InternalSystemMonitoringOperations(monitoredHost);
sysMonitoringActions.initializeMonitoring(new ArrayList<FullReadingBean>(readings), startTimestamp, pollInterval);
} catch (AgentException e) {
throw new MonitoringException("Could not start the system monitoring process on " + monitoredHost + ". For more details check loader logs on that machine", e);
}
}
Aggregations