Search in sources :

Example 6 with Agent

use of org.opencastproject.capture.admin.api.Agent in project opencast by opencast.

the class CaptureAgentStateServiceImpl method getAgent.

/**
 * {@inheritDoc}
 *
 * @see org.opencastproject.capture.admin.api.CaptureAgentStateService#getAgent(java.lang.String)
 */
@Override
public Agent getAgent(String name) throws NotFoundException {
    String org = securityService.getOrganization().getId();
    Agent agent = getAgent(name, org);
    return updateCachedLastHeardFrom(agent, org);
}
Also used : Agent(org.opencastproject.capture.admin.api.Agent)

Example 7 with Agent

use of org.opencastproject.capture.admin.api.Agent in project opencast by opencast.

the class CaptureAgentStateServiceImplTest method verifyAgent.

private void verifyAgent(String name, String state, Properties caps) {
    try {
        Agent agent = service.getAgent(name);
        assertEquals(name, agent.getName());
        assertEquals(state, agent.getState());
        assertEquals(caps, agent.getCapabilities());
    } catch (NotFoundException e) {
        if (state != null)
            fail();
    }
}
Also used : Agent(org.opencastproject.capture.admin.api.Agent) NotFoundException(org.opencastproject.util.NotFoundException)

Example 8 with Agent

use of org.opencastproject.capture.admin.api.Agent in project opencast by opencast.

the class CaptureAgentStateServiceImplTest method testUpdatedTimeSinceLastUpdate.

@Test
public void testUpdatedTimeSinceLastUpdate() throws Exception {
    // See MH-10031
    String name = "agent1";
    Long lastHeardFrom = 0L;
    Agent agent = null;
    service.setAgentState(name, IDLE);
    agent = service.getAgent(name);
    lastHeardFrom = agent.getLastHeardFrom();
    service.setAgentState(name, CAPTURING);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    lastHeardFrom = agent.getLastHeardFrom();
    service.setAgentState(name, IDLE);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    lastHeardFrom = agent.getLastHeardFrom();
    Prelude.sleep(100L);
    service.setAgentState(name, IDLE);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    lastHeardFrom = agent.getLastHeardFrom();
    service.setAgentState(name, UNKNOWN);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom.equals(agent.getLastHeardFrom()));
}
Also used : Agent(org.opencastproject.capture.admin.api.Agent) Test(org.junit.Test)

Example 9 with Agent

use of org.opencastproject.capture.admin.api.Agent in project opencast by opencast.

the class CaptureAgentStateServiceImplTest method testAgentStateTimeout.

@Test
public void testAgentStateTimeout() throws Exception {
    service.setupAgentCache(1, TimeUnit.SECONDS);
    String name = "agent1";
    Long lastHeardFrom = 0L;
    Agent agent = null;
    service.setAgentState(name, IDLE);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    assertTrue(agent.getLastHeardFrom() <= System.currentTimeMillis());
    Thread.sleep(1500);
    assertEquals(OFFLINE, service.getAgentState(name));
}
Also used : Agent(org.opencastproject.capture.admin.api.Agent) Test(org.junit.Test)

Example 10 with Agent

use of org.opencastproject.capture.admin.api.Agent in project opencast by opencast.

the class CaptureAgentStateServiceImplTest method testAgentReturn.

@Test
public void testAgentReturn() throws Exception {
    service.setupAgentCache(1, TimeUnit.SECONDS);
    String name = "agent1";
    Long lastHeardFrom = 0L;
    Agent agent = null;
    service.setAgentState(name, IDLE);
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    assertTrue(agent.getLastHeardFrom() <= System.currentTimeMillis());
    Thread.sleep(1500);
    Map<String, Agent> agents = service.getKnownAgents();
    assertEquals(OFFLINE, agents.get(name).getState());
    assertEquals(OFFLINE, service.getAgentState(name));
    service.setAgentState(name, IDLE);
    long time = System.currentTimeMillis();
    agent = service.getAgent(name);
    assertTrue(lastHeardFrom <= agent.getLastHeardFrom());
    assertTrue(time - agent.getLastHeardFrom() <= 5);
}
Also used : Agent(org.opencastproject.capture.admin.api.Agent) Test(org.junit.Test)

Aggregations

Agent (org.opencastproject.capture.admin.api.Agent)15 Path (javax.ws.rs.Path)5 RestQuery (org.opencastproject.util.doc.rest.RestQuery)5 Produces (javax.ws.rs.Produces)4 Test (org.junit.Test)4 NotFoundException (org.opencastproject.util.NotFoundException)4 GET (javax.ws.rs.GET)3 JValue (com.entwinemedia.fn.data.json.JValue)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 EntityManager (javax.persistence.EntityManager)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 AgentStateUpdate (org.opencastproject.capture.admin.api.AgentStateUpdate)2 MediaPackage (org.opencastproject.mediapackage.MediaPackage)2 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)2 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1