Search in sources :

Example 31 with JobVertexID

use of org.apache.flink.runtime.jobgraph.JobVertexID in project flink by apache.

the class ExecutionVertexStopTest method testStopRpc.

@Test
public void testStopRpc() throws Exception {
    final JobVertexID jid = new JobVertexID();
    final ExecutionJobVertex ejv = getExecutionVertex(jid);
    final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
    final ExecutionAttemptID execId = vertex.getCurrentExecutionAttempt().getAttemptId();
    setVertexState(vertex, ExecutionState.SCHEDULED);
    assertEquals(ExecutionState.SCHEDULED, vertex.getExecutionState());
    final ActorGateway gateway = new StopSequenceInstanceGateway(TestingUtils.defaultExecutionContext());
    Instance instance = getInstance(new ActorTaskManagerGateway(gateway));
    SimpleSlot slot = instance.allocateSimpleSlot(new JobID());
    vertex.deployToSlot(slot);
    receivedStopSignal = false;
    vertex.stop();
    assertTrue(receivedStopSignal);
}
Also used : Instance(org.apache.flink.runtime.instance.Instance) ExecutionGraphTestUtils.getInstance(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getInstance) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) BaseTestingActorGateway(org.apache.flink.runtime.instance.BaseTestingActorGateway) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) JobID(org.apache.flink.api.common.JobID) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 32 with JobVertexID

use of org.apache.flink.runtime.jobgraph.JobVertexID in project flink by apache.

the class ExecutionVertexStopTest method testStop.

@Test
public void testStop() throws Exception {
    final JobVertexID jid = new JobVertexID();
    final ExecutionJobVertex ejv = getExecutionVertex(jid);
    Execution executionMock = mock(Execution.class);
    whenNew(Execution.class).withAnyArguments().thenReturn(executionMock);
    final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
    vertex.stop();
    verify(executionMock).stop();
}
Also used : JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 33 with JobVertexID

use of org.apache.flink.runtime.jobgraph.JobVertexID in project flink by apache.

the class LegacyJobVertexIdTest method testIntroduceLegacyJobVertexIds.

@Test
public void testIntroduceLegacyJobVertexIds() throws Exception {
    JobVertexID defaultId = new JobVertexID();
    JobVertexID legacyId1 = new JobVertexID();
    JobVertexID legacyId2 = new JobVertexID();
    JobVertex jobVertex = new JobVertex("test", defaultId, Arrays.asList(legacyId1, legacyId2));
    jobVertex.setInvokableClass(AbstractInvokable.class);
    ExecutionGraph executionGraph = new ExecutionGraph(mock(ScheduledExecutorService.class), mock(Executor.class), new JobID(), "test", mock(Configuration.class), mock(SerializedValue.class), Time.seconds(1), mock(RestartStrategy.class), mock(SlotProvider.class));
    ExecutionJobVertex executionJobVertex = new ExecutionJobVertex(executionGraph, jobVertex, 1, Time.seconds(1));
    Map<JobVertexID, ExecutionJobVertex> idToVertex = new HashMap<>();
    idToVertex.put(executionJobVertex.getJobVertexId(), executionJobVertex);
    Assert.assertEquals(executionJobVertex, idToVertex.get(defaultId));
    Assert.assertNull(idToVertex.get(legacyId1));
    Assert.assertNull(idToVertex.get(legacyId2));
    idToVertex = ExecutionJobVertex.includeLegacyJobVertexIDs(idToVertex);
    Assert.assertEquals(3, idToVertex.size());
    Assert.assertEquals(executionJobVertex, idToVertex.get(defaultId));
    Assert.assertEquals(executionJobVertex, idToVertex.get(legacyId1));
    Assert.assertEquals(executionJobVertex, idToVertex.get(legacyId2));
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) SlotProvider(org.apache.flink.runtime.instance.SlotProvider) Configuration(org.apache.flink.configuration.Configuration) HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) RestartStrategy(org.apache.flink.runtime.executiongraph.restart.RestartStrategy) SerializedValue(org.apache.flink.util.SerializedValue) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) Executor(java.util.concurrent.Executor) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 34 with JobVertexID

use of org.apache.flink.runtime.jobgraph.JobVertexID in project flink by apache.

the class ProgrammedSlotProvider method allocateSlot.

@Override
public Future<SimpleSlot> allocateSlot(ScheduledUnit task, boolean allowQueued) {
    JobVertexID vertexId = task.getTaskToExecute().getVertex().getJobvertexId();
    int subtask = task.getTaskToExecute().getParallelSubtaskIndex();
    Future<SimpleSlot>[] forTask = slotFutures.get(vertexId);
    if (forTask != null) {
        Future<SimpleSlot> future = forTask[subtask];
        if (future != null) {
            return future;
        }
    }
    throw new IllegalArgumentException("No registered slot future for task " + vertexId + " (" + subtask + ')');
}
Also used : JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) Future(org.apache.flink.runtime.concurrent.Future) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot)

Example 35 with JobVertexID

use of org.apache.flink.runtime.jobgraph.JobVertexID in project flink by apache.

the class TerminalStateDeadlockTest method testProvokeDeadlock.

// ------------------------------------------------------------------------
@Test
public void testProvokeDeadlock() {
    try {
        final JobID jobId = resource.getJobID();
        final JobVertexID vid1 = new JobVertexID();
        final JobVertexID vid2 = new JobVertexID();
        final List<JobVertex> vertices;
        {
            JobVertex v1 = new JobVertex("v1", vid1);
            JobVertex v2 = new JobVertex("v2", vid2);
            v1.setParallelism(1);
            v2.setParallelism(1);
            v1.setInvokableClass(DummyInvokable.class);
            v2.setInvokableClass(DummyInvokable.class);
            vertices = Arrays.asList(v1, v2);
        }
        final Scheduler scheduler = new Scheduler(TestingUtils.defaultExecutionContext());
        final Executor executor = Executors.newFixedThreadPool(4);
        // try a lot!
        for (int i = 0; i < 20000; i++) {
            final TestExecGraph eg = new TestExecGraph(jobId);
            eg.attachJobGraph(vertices);
            final Execution e1 = eg.getJobVertex(vid1).getTaskVertices()[0].getCurrentExecutionAttempt();
            final Execution e2 = eg.getJobVertex(vid2).getTaskVertices()[0].getCurrentExecutionAttempt();
            initializeExecution(e1);
            initializeExecution(e2);
            execGraphStateField.set(eg, JobStatus.FAILING);
            execGraphSlotProviderField.set(eg, scheduler);
            Runnable r1 = new Runnable() {

                @Override
                public void run() {
                    e1.cancelingComplete();
                }
            };
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    e2.cancelingComplete();
                }
            };
            executor.execute(r1);
            executor.execute(r2);
            eg.waitTillDone();
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) Executor(java.util.concurrent.Executor) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) DummyInvokable(org.apache.flink.runtime.operators.testutils.DummyInvokable) JobID(org.apache.flink.api.common.JobID) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)191 Test (org.junit.Test)145 JobID (org.apache.flink.api.common.JobID)88 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)46 HashMap (java.util.HashMap)38 Configuration (org.apache.flink.configuration.Configuration)33 Instance (org.apache.flink.runtime.instance.Instance)33 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)30 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)30 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)28 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)27 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)25 IOException (java.io.IOException)24 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)24 ExecutionException (java.util.concurrent.ExecutionException)23 ActorTaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)22 ArrayList (java.util.ArrayList)20 ActorRef (akka.actor.ActorRef)18 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)18 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)15