Search in sources :

Example 1 with RemoteExecutor

use of com.axway.ats.agent.webapp.client.executors.RemoteExecutor in project ats-framework by Axway.

the class EnvironmentCleanupClient method restoreFrom.

/**
     * Restore the component environment from a specific folder using a specific environment configuration
     *
     * @param componentName the name of the component
     * @param environmentName the name of the environment configuration
     * @param folderPath the backup folder to use for restore
     * @throws AgentException
     */
@PublicAtsApi
public void restoreFrom(String componentName, String environmentName, String folderPath) throws AgentException {
    log.info("Executing restore for component '" + componentName + "' using environment '" + environmentName + "' from folder '" + folderPath + "'");
    if (atsAgent.equals(LOCAL_JVM)) {
        LocalExecutor localExecutor = new LocalExecutor();
        localExecutor.restore(componentName, environmentName, folderPath);
    } else {
        RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
        remoteExecutor.restore(componentName, environmentName, folderPath);
    }
    log.info("Finished executing restore for component '" + componentName + "' using environment '" + environmentName + "' from folder '" + folderPath + "'");
}
Also used : RemoteExecutor(com.axway.ats.agent.webapp.client.executors.RemoteExecutor) LocalExecutor(com.axway.ats.agent.webapp.client.executors.LocalExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 2 with RemoteExecutor

use of com.axway.ats.agent.webapp.client.executors.RemoteExecutor in project ats-framework by Axway.

the class EnvironmentCleanupClient method restore.

/**
     * Restore the environment 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 restore(String componentName, String environmentName) throws AgentException {
    log.info("Executing restore for component '" + componentName + "' using environment configuration '" + environmentName + "'");
    if (atsAgent.equals(LOCAL_JVM)) {
        LocalExecutor localExecutor = new LocalExecutor();
        localExecutor.restore(componentName, environmentName, null);
    } else {
        RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
        remoteExecutor.restore(componentName, environmentName, null);
    }
    log.info("Finished executing restore for component '" + componentName + "' using environment configuration '" + environmentName + "'");
}
Also used : RemoteExecutor(com.axway.ats.agent.webapp.client.executors.RemoteExecutor) LocalExecutor(com.axway.ats.agent.webapp.client.executors.LocalExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with RemoteExecutor

use of com.axway.ats.agent.webapp.client.executors.RemoteExecutor in project ats-framework by Axway.

the class EnvironmentCleanupClient method backupAllComponents.

/**
     * Create backup for all registered components
     *
     * @throws AgentException
     */
@PublicAtsApi
public void backupAllComponents() throws AgentException {
    log.info("Executing backup for all registered components");
    if (atsAgent.equals(LOCAL_JVM)) {
        LocalExecutor localExecutor = new LocalExecutor();
        localExecutor.backupAll(null);
    } else {
        RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
        remoteExecutor.backupAll(null);
    }
    log.info("Finished executing backup for all registered components");
}
Also used : RemoteExecutor(com.axway.ats.agent.webapp.client.executors.RemoteExecutor) LocalExecutor(com.axway.ats.agent.webapp.client.executors.LocalExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with RemoteExecutor

use of com.axway.ats.agent.webapp.client.executors.RemoteExecutor in project ats-framework by Axway.

the class EnvironmentCleanupClient method backupTo.

/**
     * Create backup for given component to specific backup folder
     *
     * @param componentName the name of the component
     * @param environmentName the name of the environment configuration
     * @param folderPath backup folder path
     * @throws AgentException
     */
@PublicAtsApi
public void backupTo(String componentName, String folderPath) throws AgentException {
    log.info("Executing backup for component '" + componentName + "' to folder '" + folderPath + "'");
    if (atsAgent.equals(LOCAL_JVM)) {
        LocalExecutor localExecutor = new LocalExecutor();
        localExecutor.backup(componentName, null, folderPath);
    } else {
        RemoteExecutor remoteExecutor = new RemoteExecutor(atsAgent);
        remoteExecutor.backup(componentName, null, folderPath);
    }
    log.info("Finished executing backup for component '" + componentName + "' to folder '" + folderPath + "'");
}
Also used : RemoteExecutor(com.axway.ats.agent.webapp.client.executors.RemoteExecutor) LocalExecutor(com.axway.ats.agent.webapp.client.executors.LocalExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 5 with RemoteExecutor

use of com.axway.ats.agent.webapp.client.executors.RemoteExecutor 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) {
            }
        }
    }
}
Also used : ActionRequest(com.axway.ats.agent.core.action.ActionRequest) RemoteExecutor(com.axway.ats.agent.webapp.client.executors.RemoteExecutor) AbstractClientExecutor(com.axway.ats.agent.webapp.client.executors.AbstractClientExecutor) LocalExecutor(com.axway.ats.agent.webapp.client.executors.LocalExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

LocalExecutor (com.axway.ats.agent.webapp.client.executors.LocalExecutor)10 RemoteExecutor (com.axway.ats.agent.webapp.client.executors.RemoteExecutor)10 PublicAtsApi (com.axway.ats.common.PublicAtsApi)9 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)2 AbstractClientExecutor (com.axway.ats.agent.webapp.client.executors.AbstractClientExecutor)1