Search in sources :

Example 1 with PollData

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;
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData)

Example 2 with PollData

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"));
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with PollData

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);
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData) Test(org.junit.Test)

Example 4 with 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);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) SQLException(java.sql.SQLException) PollData(com.netflix.conductor.common.metadata.tasks.PollData) Connection(java.sql.Connection)

Example 5 with PollData

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));
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData)

Aggregations

PollData (com.netflix.conductor.common.metadata.tasks.PollData)17 Test (org.junit.Test)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 Task (com.netflix.conductor.common.metadata.tasks.Task)4 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)4 Workflow (com.netflix.conductor.common.run.Workflow)4 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)4 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)3 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)3 HashMap (java.util.HashMap)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 Status (com.netflix.conductor.common.metadata.tasks.Task.Status)1 COMPLETED (com.netflix.conductor.common.metadata.tasks.Task.Status.COMPLETED)1 COMPLETED_WITH_ERRORS (com.netflix.conductor.common.metadata.tasks.Task.Status.COMPLETED_WITH_ERRORS)1 FAILED (com.netflix.conductor.common.metadata.tasks.Task.Status.FAILED)1 IN_PROGRESS (com.netflix.conductor.common.metadata.tasks.Task.Status.IN_PROGRESS)1 SCHEDULED (com.netflix.conductor.common.metadata.tasks.Task.Status.SCHEDULED)1