use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class AbstractProtoMapper method fromProto.
public PollData fromProto(PollDataPb.PollData from) {
PollData to = new PollData();
to.setQueueName(from.getQueueName());
to.setDomain(from.getDomain());
to.setWorkerId(from.getWorkerId());
to.setLastPollTime(from.getLastPollTime());
return to;
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class TaskResourceTest method testGetPollData.
@Test
public void testGetPollData() throws Exception {
PollData pollData = new PollData("queue", "test", "w123", 100);
List<PollData> listOfPollData = new ArrayList<>();
listOfPollData.add(pollData);
when(mockTaskService.getPollData(anyString())).thenReturn(listOfPollData);
assertEquals(listOfPollData, taskResource.getPollData("w123"));
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class PollDataDAOTest method testPollData.
@Test
public void testPollData() {
getPollDataDAO().updateLastPollData("taskDef", null, "workerId1");
PollData pollData = getPollDataDAO().getPollData("taskDef", null);
assertNotNull(pollData);
assertTrue(pollData.getLastPollTime() > 0);
assertEquals(pollData.getQueueName(), "taskDef");
assertNull(pollData.getDomain());
assertEquals(pollData.getWorkerId(), "workerId1");
getPollDataDAO().updateLastPollData("taskDef", "domain1", "workerId1");
pollData = getPollDataDAO().getPollData("taskDef", "domain1");
assertNotNull(pollData);
assertTrue(pollData.getLastPollTime() > 0);
assertEquals(pollData.getQueueName(), "taskDef");
assertEquals(pollData.getDomain(), "domain1");
assertEquals(pollData.getWorkerId(), "workerId1");
List<PollData> pData = getPollDataDAO().getPollData("taskDef");
assertEquals(pData.size(), 2);
pollData = getPollDataDAO().getPollData("taskDef", "domain2");
assertNull(pollData);
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class MySQLExecutionDAO method getAllPollData.
@Override
public List<PollData> getAllPollData() {
try (Connection tx = dataSource.getConnection()) {
boolean previousAutoCommitMode = tx.getAutoCommit();
tx.setAutoCommit(true);
try {
String GET_ALL_POLL_DATA = "SELECT json_data FROM poll_data ORDER BY queue_name";
return query(tx, GET_ALL_POLL_DATA, q -> q.executeAndFetch(PollData.class));
} catch (Throwable th) {
throw new ApplicationException(BACKEND_ERROR, th.getMessage(), th);
} finally {
tx.setAutoCommit(previousAutoCommitMode);
}
} catch (SQLException ex) {
throw new ApplicationException(BACKEND_ERROR, ex.getMessage(), ex);
}
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class PostgresExecutionDAO method updateLastPollData.
@Override
public void updateLastPollData(String taskDefName, String domain, String workerId) {
Preconditions.checkNotNull(taskDefName, "taskDefName name cannot be null");
PollData pollData = new PollData(taskDefName, domain, workerId, System.currentTimeMillis());
String effectiveDomain = (domain == null) ? "DEFAULT" : domain;
withTransaction(tx -> insertOrUpdatePollData(tx, pollData, effectiveDomain));
}
Aggregations