use of com.axway.ats.agent.webapp.client.executors.LocalExecutor in project ats-framework by Axway.
the class AgentConfigurationClient method isComponentLoaded.
/**
* Tells if an Agent component is loaded, so its actions can be called.
* This method will wait for the specified timeout period until the wanted condition is met.
*
* @param componentName the name of the component
* @param timeout maximum timeout (in seconds) to wait for the component to be loaded.
* @return whether it is available
*/
@PublicAtsApi
public boolean isComponentLoaded(String componentName, int timeout) throws AgentException {
// construct an action request
ActionRequest actionRequest = new ActionRequest(componentName, "fake action name", new Object[] {});
AbstractClientExecutor executor;
if (atsAgent.equals(LOCAL_JVM)) {
executor = new LocalExecutor();
} else {
executor = new RemoteExecutor(atsAgent, false);
}
long startTimestamp = System.currentTimeMillis();
while (true) {
if (executor.isComponentLoaded(actionRequest)) {
// it is loaded
return true;
} else if (System.currentTimeMillis() - startTimestamp > timeout * 1000) {
// not loaded for the whole timeout
return false;
} else {
// not loaded, but we will check again
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}
use of com.axway.ats.agent.webapp.client.executors.LocalExecutor in project ats-framework by Axway.
the class ActionClient method executeAction.
/**
* Execute the given action
*
* @param actionName
* name of the action
* @param arguments
* arguments for the action
* @return result of the action execution
* @throws AgentException
* if exception occurs during action execution
*/
protected Object executeAction(String actionName, Object[] arguments) throws AgentException {
// construct an action request
ActionRequest actionRequest = new ActionRequest(component, actionName, arguments);
// the returned result
Object result = null;
// Check if we are queuing - in this case all actions will be routed to the queue
// The exception is when we are sending command to the Monitoring Service
ActionQueue actionQueue = ActionQueue.getCurrentInstance();
if (!actionQueue.isInQueueMode() || component.equals(SystemMonitorDefinitions.ATS_SYSTEM_MONITORING_COMPONENT_NAME)) {
if (atsAgent.equals(LOCAL_JVM)) {
LocalExecutor localExecutor = new LocalExecutor();
result = localExecutor.executeAction(actionRequest);
} else {
RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
result = remoteExecutor.executeAction(actionRequest);
}
} else {
actionQueue.addActionRequest(actionRequest);
}
return result;
}
use of com.axway.ats.agent.webapp.client.executors.LocalExecutor in project ats-framework by Axway.
the class EnvironmentCleanupClient method restoreAllComponents.
/**
* Restore the environment for all components with a specific environment configuration
* Keep in mind that all the components must have environment configuration with this name
*
* @throws AgentException
*/
@PublicAtsApi
public void restoreAllComponents(String environmentName) throws AgentException {
log.info("Executing cleanup for all registered components using environment configuration '" + environmentName + "'");
if (atsAgent.equals(LOCAL_JVM)) {
LocalExecutor localExecutor = new LocalExecutor();
localExecutor.restoreAll(environmentName);
} else {
RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
remoteExecutor.restoreAll(environmentName);
}
log.info("Finished executing cleanup for all registered components using environment configuration '" + environmentName + "'");
}
use of com.axway.ats.agent.webapp.client.executors.LocalExecutor in project ats-framework by Axway.
the class EnvironmentCleanupClient method backup.
/**
* Create backup for given component with a specific environment configuration
*
* @param componentName the name of the component
* @param environmentName the name of the environment configuration
* @throws AgentException
*/
@PublicAtsApi
public void backup(String componentName, String environmentName) throws AgentException {
log.info("Executing backup for component '" + componentName + "' using environment '" + environmentName + "'");
if (atsAgent.equals(LOCAL_JVM)) {
LocalExecutor localExecutor = new LocalExecutor();
localExecutor.backup(componentName, environmentName, null);
} else {
RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
remoteExecutor.backup(componentName, environmentName, null);
}
log.info("Finished executing backup for component '" + componentName + "' using environment '" + environmentName + "'");
}
use of com.axway.ats.agent.webapp.client.executors.LocalExecutor in project ats-framework by Axway.
the class EnvironmentCleanupClient method backupAllComponents.
/**
* Create backup for all registered components with a specific environment configuration
* Keep in mind that all the components must have environment configuration with this name
*
* @param environmentName the name of the environment configuration
* @throws AgentException
*/
@PublicAtsApi
public void backupAllComponents(String environmentName) throws AgentException {
log.info("Executing backup for all registered components using environment configuration '" + environmentName + "'");
if (atsAgent.equals(LOCAL_JVM)) {
LocalExecutor localExecutor = new LocalExecutor();
localExecutor.backupAll(environmentName);
} else {
RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
remoteExecutor.backupAll(environmentName);
}
log.info("Finished executing backup for all registered components using environment configuration '" + environmentName + "'");
}
Aggregations