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