Search in sources :

Example 1 with AgentService

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);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception)

Example 2 with AgentService

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;
}
Also used : AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) ArrayList(java.util.ArrayList) ArgumentWrapper(com.axway.ats.agent.webapp.client.ArgumentWrapper) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) ObjectOutputStream(java.io.ObjectOutputStream) AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentService(com.axway.ats.agent.webapp.client.AgentService) ByteArrayInputStream(java.io.ByteArrayInputStream) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) ObjectInputStream(java.io.ObjectInputStream)

Example 3 with AgentService

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);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException)

Example 4 with AgentService

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);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception)

Example 5 with AgentService

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);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) ByteArrayInputStream(java.io.ByteArrayInputStream) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ArrayList(java.util.ArrayList) List(java.util.List) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)14 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)14 AgentService (com.axway.ats.agent.webapp.client.AgentService)14 IOException (java.io.IOException)11 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)10 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)10 ArrayList (java.util.ArrayList)5 ImportantThread (com.axway.ats.agent.core.threading.ImportantThread)2 LoadQueueResult (com.axway.ats.log.model.LoadQueueResult)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)1 Configurator (com.axway.ats.agent.core.configuration.Configurator)1 RemoteLoggingConfigurator (com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator)1 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)1 ThreadingPattern (com.axway.ats.agent.core.threading.patterns.ThreadingPattern)1 ActionWrapper (com.axway.ats.agent.webapp.client.ActionWrapper)1 ArgumentWrapper (com.axway.ats.agent.webapp.client.ArgumentWrapper)1