Search in sources :

Example 6 with SessionData

use of com.axway.ats.agent.webapp.restservice.model.SessionData in project ats-framework by Axway.

the class MonitoringServiceImpl method scheduleUserActivity.

@POST
@Path("scheduleUserActivity")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleUserActivity(@Context HttpServletRequest request, BasePojo basePojo) {
    final String caller = getCaller(request, basePojo, false);
    ThreadsPerCaller.registerThread(caller);
    try {
        SessionData sd = getSessionData(request, basePojo);
        RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
        String agent = request.getLocalAddr() + ":" + request.getLocalPort();
        restSystemMonitor.scheduleUserActivity(agent);
    } catch (Exception e) {
        return Response.serverError().entity(new ErrorPojo(e)).build();
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
    String statusMessage = "{\"status \": \"scheduled user activity monitoring.\"}";
    return Response.ok(statusMessage).build();
}
Also used : ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 7 with SessionData

use of com.axway.ats.agent.webapp.restservice.model.SessionData in project ats-framework by Axway.

the class MonitoringServiceImpl method scheduleChildProcessMonitoring.

@POST
@Path("scheduleChildProcessMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleChildProcessMonitoring(@Context HttpServletRequest request, ScheduleProcessMonitoringPojo monitoringPojo) {
    final String caller = getCaller(request, monitoringPojo, false);
    ThreadsPerCaller.registerThread(caller);
    try {
        SessionData sd = getSessionData(request, monitoringPojo);
        RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
        String agent = request.getLocalAddr() + ":" + request.getLocalPort();
        Set<ReadingBean> readings = restSystemMonitor.scheduleChildProcessMonitoring(agent, monitoringPojo.getParentProcess(), monitoringPojo.getProcessPattern(), monitoringPojo.getProcessAlias(), monitoringPojo.getProcessUsername(), monitoringPojo.getProcessReadingTypes());
        restSystemMonitor.setScheduledReadingTypes(readings);
    } catch (Exception e) {
        return Response.serverError().entity(new ErrorPojo(e)).build();
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
    String statusMessage = "{\"status \": \"scheduled child process monitoring with parameters '" + monitoringPojo.toString() + "'\"}";
    return Response.ok(statusMessage).build();
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 8 with SessionData

use of com.axway.ats.agent.webapp.restservice.model.SessionData in project ats-framework by Axway.

the class AgentConfigurationServiceImpl method joinTestcase.

/**
 * Tell the DbEventRequestProcess which run and test must receive the DB
 * messages/data
 */
@POST
@Path("joinTestcase")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response joinTestcase(@Context HttpServletRequest request, JoinTestcasePojo testCaseStatePojo) {
    final String caller = getCaller(request, testCaseStatePojo, false);
    ThreadsPerCaller.registerThread(caller);
    try {
        SessionData sd = getSessionData(request, testCaseStatePojo);
        RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
        // cancel all action tasks, that are started on an agent, located on
        // the current caller host.
        // current caller and the agent must have the same IP, in order for
        // the queue to be cancelled
        dbLog.debug("Cancelling all action task on the agent, that were started form the current caller.");
        MultiThreadedActionHandler.cancellAllQueuesFromAgent(ThreadsPerCaller.getCaller());
        // cancel all running system monitoring tasks on the agent
        dbLog.debug("Cancelling all running system monitoring tasks on the agent, that were started form the current caller.");
        String agent = request.getLocalAddr() + ":" + request.getLocalPort();
        restSystemMonitor.stopMonitoring(agent);
        TestCaseState newTestCaseState = new TestCaseState();
        newTestCaseState.setRunId(testCaseStatePojo.getRunId());
        newTestCaseState.setTestcaseId(testCaseStatePojo.getTestcaseId());
        newTestCaseState.setLastExecutedTestcaseId(testCaseStatePojo.getLastExecutedTestcaseId());
        // get the current state on the agent
        TestCaseState currentState = dbLog.getCurrentTestCaseState();
        boolean joinToNewTescase = true;
        if (currentState != null && currentState.isInitialized()) {
            /* This agent is already configured.
                 *
                 * Now check if the state is the same as the new one, this would mean we are trying to
                 * configure this agent for second time.
                 * This is normal as we get here when Test Executor or another agent calls this agent for first time.
                 *
                 * If the state is different, we hit an error which means this agent did not get On Test End event
                 * for the previous test case.
                 */
            if (!currentState.equals(newTestCaseState)) {
                dbLog.error("This test appears to be aborted by the user on the test executor side, but it kept running on the agent side." + " Now we cancel any further logging from the agent.");
                dbLog.leaveTestCase();
            } else {
                joinToNewTescase = false;
            }
        }
        if (joinToNewTescase) {
            /* previous RestSystemMonitor instance is still in the sessionData for that caller 
                 * so we create new RestSystemMonitor for this caller
                 * */
            restSystemMonitor = new RestSystemMonitor();
            sd.setSystemMonitor(restSystemMonitor);
            dbLog.joinTestCase(newTestCaseState);
            logClassPath(newTestCaseState);
            return Response.ok("{\"status\": \"testcase joined.\"}").build();
        } else {
            return Response.ok("{\"status\": \"testcase already joined.\"}").build();
        }
    } catch (Exception e) {
        return Response.serverError().entity(new ErrorPojo(e)).build();
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
}
Also used : ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) TestCaseState(com.axway.ats.log.autodb.TestCaseState) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 9 with SessionData

use of com.axway.ats.agent.webapp.restservice.model.SessionData in project ats-framework by Axway.

the class MonitoringServiceImpl method startMonitoring.

@POST
@Path("startMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response startMonitoring(@Context HttpServletRequest request, StartMonitoringPojo monitoringPojo) {
    final String caller = getCaller(request, monitoringPojo, false);
    ThreadsPerCaller.registerThread(caller);
    try {
        SessionData sd = getSessionData(request, monitoringPojo);
        RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
        String agent = request.getLocalAddr() + ":" + request.getLocalPort();
        // calculate the time offset between the agent and the test executor
        long timeOffset = System.currentTimeMillis() - monitoringPojo.getStartTimestamp();
        restSystemMonitor.startMonitoring(agent, monitoringPojo.getStartTimestamp(), monitoringPojo.getPollingInterval(), timeOffset);
        return Response.ok("{\"status\":\"monitoring started on every " + monitoringPojo.getPollingInterval() + " seconds.\"}").build();
    } catch (Exception e) {
        return Response.serverError().entity(new ErrorPojo(e)).build();
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
}
Also used : ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 10 with SessionData

use of com.axway.ats.agent.webapp.restservice.model.SessionData in project ats-framework by Axway.

the class MonitoringServiceImpl method scheduleJvmMonitoring.

@POST
@Path("scheduleJvmMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleJvmMonitoring(@Context HttpServletRequest request, ScheduleJvmMonitoringPojo monitoringPojo) {
    final String caller = getCaller(request, monitoringPojo, false);
    ThreadsPerCaller.registerThread(caller);
    try {
        SessionData sd = getSessionData(request, monitoringPojo);
        RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
        String agent = request.getLocalAddr() + ":" + request.getLocalPort();
        Set<ReadingBean> readings = restSystemMonitor.scheduleJvmMonitoring(agent, monitoringPojo.getJvmPort(), (monitoringPojo.getAlias() == null) ? "" : monitoringPojo.getAlias(), monitoringPojo.getJvmReadingTypes());
        restSystemMonitor.setScheduledReadingTypes(readings);
    } catch (Exception e) {
        return Response.serverError().entity(new ErrorPojo(e)).build();
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
    String statusMessage = "{\"status \": \"scheduled JVM monitoring with parameters '" + monitoringPojo.toString() + "'\"}";
    return Response.ok(statusMessage).build();
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

SessionData (com.axway.ats.agent.webapp.restservice.model.SessionData)13 ErrorPojo (com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo)11 POST (javax.ws.rs.POST)11 Path (javax.ws.rs.Path)11 Produces (javax.ws.rs.Produces)11 Consumes (javax.ws.rs.Consumes)10 ReadingBean (com.axway.ats.common.performance.monitor.beans.ReadingBean)6 TestCaseState (com.axway.ats.log.autodb.TestCaseState)2 RestSystemMonitor (com.axway.ats.agent.webapp.restservice.RestSystemMonitor)1 SessionNotFoundException (com.axway.ats.agent.webapp.restservice.exceptions.SessionNotFoundException)1 WebMethod (javax.jws.WebMethod)1