Search in sources :

Example 1 with TaskId

use of io.prestosql.execution.TaskId in project hetu-core by openlookeng.

the class TestDynamicFilterUtil method registerDf.

public static void registerDf(String filterId, Session session, JoinNode.DistributionType joinType, DynamicFilterService dynamicFilterService) {
    JoinNode node = mock(JoinNode.class);
    HashMap<String, Symbol> dfs = new HashMap<>();
    List<JoinNode.EquiJoinClause> criteria = new ArrayList<JoinNode.EquiJoinClause>();
    Symbol right = new Symbol("rightCol");
    Symbol left = new Symbol("leftCol");
    JoinNode.EquiJoinClause clause = new JoinNode.EquiJoinClause(left, right);
    criteria.add(clause);
    dfs.put(filterId, right);
    when(node.getCriteria()).thenReturn(criteria);
    when(node.getDynamicFilters()).thenReturn(dfs);
    when(node.getDistributionType()).thenReturn(Optional.of(joinType));
    RemoteSourceNode leftNode = mock(RemoteSourceNode.class);
    when(node.getLeft()).thenReturn(leftNode);
    HashSet<TaskId> tasks = new HashSet<>();
    tasks.add(new TaskId("task1.0"));
    tasks.add(new TaskId("task1.1"));
    StageStateMachine stateMachine = mock(StageStateMachine.class);
    when(stateMachine.getSession()).thenReturn(session);
    InternalNode worker = mock(InternalNode.class);
    InternalNode worker2 = mock(InternalNode.class);
    HashSet<InternalNode> workers = new HashSet<>();
    when(worker.getNodeIdentifier()).thenReturn("w1");
    when(worker2.getNodeIdentifier()).thenReturn("w2");
    workers.add(worker);
    workers.add(worker2);
    dynamicFilterService.registerTasks(node, tasks, workers, stateMachine);
}
Also used : TaskId(io.prestosql.execution.TaskId) HashMap(java.util.HashMap) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) StageStateMachine(io.prestosql.execution.StageStateMachine) InternalNode(io.prestosql.metadata.InternalNode) HashSet(java.util.HashSet)

Example 2 with TaskId

use of io.prestosql.execution.TaskId in project hetu-core by openlookeng.

the class TestMemoryTracking method setUpTest.

@BeforeMethod
public void setUpTest() {
    memoryPool = new MemoryPool(new MemoryPoolId("test"), memoryPoolSize);
    queryContext = new QueryContext(new QueryId("test_query"), queryMaxMemory, queryMaxTotalMemory, memoryPool, new TestingGcMonitor(), notificationExecutor, yieldExecutor, queryMaxSpillSize, spillSpaceTracker, NOOP_SNAPSHOT_UTILS);
    taskContext = queryContext.addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), notificationExecutor), testSessionBuilder().build(), true, true, OptionalInt.empty(), Optional.empty(), TESTING_SERDE_FACTORY);
    pipelineContext = taskContext.addPipelineContext(0, true, true, false);
    driverContext = pipelineContext.addDriverContext();
    operatorContext = driverContext.addOperatorContext(1, new PlanNodeId("a"), "test-operator");
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TaskId(io.prestosql.execution.TaskId) QueryId(io.prestosql.spi.QueryId) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) MemoryPoolId(io.prestosql.spi.memory.MemoryPoolId) TaskStateMachine(io.prestosql.execution.TaskStateMachine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with TaskId

use of io.prestosql.execution.TaskId in project hetu-core by openlookeng.

the class TestSnapshotStateId method testFromString.

@Test
public void testFromString() {
    String testQueryId = "testingquery";
    long snapshotId = 18L;
    int stageId = 500;
    int taskInt = 600;
    TaskId taskId = new TaskId(testQueryId, stageId, taskInt);
    SnapshotStateId notString = new SnapshotStateId(snapshotId, taskId);
    String str = notString.toString();
    SnapshotStateId withString = SnapshotStateId.fromString(str);
    Assert.assertTrue(notString.equals(withString));
}
Also used : TaskId(io.prestosql.execution.TaskId) Test(org.testng.annotations.Test)

Example 4 with TaskId

use of io.prestosql.execution.TaskId in project hetu-core by openlookeng.

the class TestSnapshotStateId method testWithSnapshotId.

@Test
public void testWithSnapshotId() {
    String queryId = "query1";
    long snapshotId = 1L;
    int stageId = 100;
    int taskId = 200;
    TaskId taskId1 = new TaskId(queryId, stageId, taskId);
    SnapshotStateId stateId = new SnapshotStateId(snapshotId, taskId1, "component");
    stateId = stateId.withSnapshotId(2);
    Assert.assertEquals(stateId.getId(), "query1/2/100/200/component");
}
Also used : TaskId(io.prestosql.execution.TaskId) Test(org.testng.annotations.Test)

Example 5 with TaskId

use of io.prestosql.execution.TaskId in project hetu-core by openlookeng.

the class TestTaskSnapshotManager method testSpilledDeleted.

@Test
public void testSpilledDeleted() throws Exception {
    queryId = new QueryId("spilleddeletedquery");
    TaskId taskId1 = new TaskId(queryId.getId(), 1, 0);
    TaskSnapshotManager snapshotManager = new TaskSnapshotManager(taskId1, 0, snapshotUtils);
    snapshotManager.setTotalComponents(1);
    QuerySnapshotManager querySnapshotManager = new QuerySnapshotManager(queryId, snapshotUtils, TEST_SNAPSHOT_SESSION);
    querySnapshotManager.addNewTask(taskId1);
    snapshotUtils.getOrCreateQuerySnapshotManager(queryId, TEST_SNAPSHOT_SESSION);
    // first store
    long firstSnapshotId = 1L;
    File dirs = new File("/tmp/test_snapshot_manager/" + queryId + "/");
    File firstFile = new File("/tmp/test_snapshot_manager/" + queryId + "/firstFile");
    dirs.mkdirs();
    firstFile.createNewFile();
    try (FileWriter fw1 = new FileWriter(firstFile)) {
        String firstStr = "first string";
        fw1.write(firstStr);
        SnapshotStateId stateId = SnapshotStateId.forOperator(firstSnapshotId, taskId1, 3, 4, 5);
        snapshotManager.storeFile(stateId, firstFile.toPath());
        snapshotManager.succeededToCapture(stateId);
    }
    // second store, then deleted
    File secondFile = new File("/tmp/test_snapshot_manager/" + queryId + "/secondFile");
    secondFile.createNewFile();
    try (FileWriter fw2 = new FileWriter(secondFile)) {
        String secondStr = "second string";
        fw2.write(secondStr);
        SnapshotStateId secondId = SnapshotStateId.forOperator(2L, taskId1, 3, 4, 5);
        snapshotManager.storeFile(secondId, secondFile.toPath());
        snapshotManager.succeededToCapture(secondId);
        querySnapshotManager.snapshotInitiated(firstSnapshotId);
        querySnapshotManager.updateQueryCapture(taskId1, Collections.singletonMap(firstSnapshotId, SnapshotInfo.withStatus(SnapshotResult.SUCCESSFUL)));
        File secondFileOperator = new File("/tmp/test_snapshot_manager/" + queryId + "/2/1/0/3/4/5/secondFile");
        assertTrue(secondFileOperator.exists());
        secondFileOperator.delete();
        assertFalse(secondFileOperator.exists());
        assertFalse(snapshotManager.loadFile(secondId, secondFile.toPath()));
    }
}
Also used : TaskId(io.prestosql.execution.TaskId) QueryId(io.prestosql.spi.QueryId) FileWriter(java.io.FileWriter) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

TaskId (io.prestosql.execution.TaskId)64 Test (org.testng.annotations.Test)48 QueryId (io.prestosql.spi.QueryId)24 Duration (io.airlift.units.Duration)10 InternalNode (io.prestosql.metadata.InternalNode)10 MockRemoteTaskFactory (io.prestosql.execution.MockRemoteTaskFactory)8 RemoteTask (io.prestosql.execution.RemoteTask)8 HashSet (java.util.HashSet)8 ImmutableList (com.google.common.collect.ImmutableList)7 TestingTicker (io.airlift.testing.TestingTicker)7 Session (io.prestosql.Session)7 Phaser (java.util.concurrent.Phaser)7 MockSplit (io.prestosql.MockSplit)6 TaskStateMachine (io.prestosql.execution.TaskStateMachine)6 Split (io.prestosql.metadata.Split)6 ConnectorSplit (io.prestosql.spi.connector.ConnectorSplit)6 TestingSplit (io.prestosql.testing.TestingSplit)6 HashMap (java.util.HashMap)6 List (java.util.List)6 DynamicFilter (io.prestosql.spi.dynamicfilter.DynamicFilter)5