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);
}
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();
}
}
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()));
}
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));
}
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);
}
Aggregations