use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class FineGrainedSlotManagerTest method testSlotAllocationAccordingToStrategyResult.
// ---------------------------------------------------------------------------------------------
// Handle result from ResourceAllocationStrategy
// ---------------------------------------------------------------------------------------------
@Test
public void testSlotAllocationAccordingToStrategyResult() throws Exception {
final CompletableFuture<Tuple6<SlotID, JobID, AllocationID, ResourceProfile, String, ResourceManagerId>> requestSlotFuture = new CompletableFuture<>();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setRequestSlotFunction(tuple6 -> {
requestSlotFuture.complete(tuple6);
return CompletableFuture.completedFuture(Acknowledge.get());
}).createTestingTaskExecutorGateway();
final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection(ResourceID.generate(), taskExecutorGateway);
final JobID jobId = new JobID();
final SlotReport slotReport = new SlotReport();
new Context() {
{
resourceAllocationStrategyBuilder.setTryFulfillRequirementsFunction(((jobIDCollectionMap, taskManagerResourceInfoProvider) -> ResourceAllocationResult.builder().addAllocationOnRegisteredResource(jobId, taskManagerConnection.getInstanceID(), DEFAULT_SLOT_RESOURCE_PROFILE).build()));
runTest(() -> {
runInMainThread(() -> {
getSlotManager().registerTaskManager(taskManagerConnection, slotReport, DEFAULT_TOTAL_RESOURCE_PROFILE, DEFAULT_SLOT_RESOURCE_PROFILE);
getSlotManager().processResourceRequirements(createResourceRequirements(jobId, 1));
});
final Tuple6<SlotID, JobID, AllocationID, ResourceProfile, String, ResourceManagerId> requestSlot = assertFutureCompleteAndReturn(requestSlotFuture);
assertEquals(jobId, requestSlot.f1);
assertEquals(DEFAULT_SLOT_RESOURCE_PROFILE, requestSlot.f3);
});
}
};
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class FineGrainedSlotManagerTest method testSlotAllocationForPendingTaskManagerWillBeRespected.
@Test
public void testSlotAllocationForPendingTaskManagerWillBeRespected() throws Exception {
final JobID jobId = new JobID();
final CompletableFuture<Void> requestResourceFuture = new CompletableFuture<>();
final PendingTaskManager pendingTaskManager = new PendingTaskManager(DEFAULT_TOTAL_RESOURCE_PROFILE, DEFAULT_NUM_SLOTS_PER_WORKER);
final CompletableFuture<Tuple6<SlotID, JobID, AllocationID, ResourceProfile, String, ResourceManagerId>> requestSlotFuture = new CompletableFuture<>();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setRequestSlotFunction(tuple6 -> {
requestSlotFuture.complete(tuple6);
return CompletableFuture.completedFuture(Acknowledge.get());
}).createTestingTaskExecutorGateway();
final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection(ResourceID.generate(), taskExecutorGateway);
new Context() {
{
resourceAllocationStrategyBuilder.setTryFulfillRequirementsFunction(((jobIDCollectionMap, taskManagerResourceInfoProvider) -> ResourceAllocationResult.builder().addPendingTaskManagerAllocate(pendingTaskManager).addAllocationOnPendingResource(jobId, pendingTaskManager.getPendingTaskManagerId(), DEFAULT_SLOT_RESOURCE_PROFILE).build()));
resourceActionsBuilder.setAllocateResourceConsumer(ignored -> requestResourceFuture.complete(null));
runTest(() -> {
runInMainThread(() -> getSlotManager().processResourceRequirements(createResourceRequirements(jobId, 1)));
assertFutureCompleteAndReturn(requestResourceFuture);
runInMainThread(() -> getSlotManager().registerTaskManager(taskManagerConnection, new SlotReport(), DEFAULT_TOTAL_RESOURCE_PROFILE, DEFAULT_SLOT_RESOURCE_PROFILE));
final Tuple6<SlotID, JobID, AllocationID, ResourceProfile, String, ResourceManagerId> requestSlot = assertFutureCompleteAndReturn(requestSlotFuture);
assertEquals(jobId, requestSlot.f1);
assertEquals(DEFAULT_SLOT_RESOURCE_PROFILE, requestSlot.f3);
});
}
};
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class JoinITCase method testProjectOnATuple1Input.
@Test
public void testProjectOnATuple1Input() throws Exception {
/*
* Project join on a tuple input 1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple6<String, Long, String, Integer, Long, Long>> joinDs = ds1.join(ds2).where(1).equalTo(1).projectFirst(2, 1).projectSecond(3).projectFirst(0).projectSecond(4, 1);
List<Tuple6<String, Long, String, Integer, Long, Long>> result = joinDs.collect();
String expected = "Hi,1,Hallo,1,1,1\n" + "Hello,2,Hallo Welt,2,2,2\n" + "Hello world,2,Hallo Welt,3,2,2\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class JoinITCase method testProjectJoinOnATuple2Input.
@Test
public void testProjectJoinOnATuple2Input() throws Exception {
/*
* Project join on a tuple input 2
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple6<String, String, Long, Long, Long, Integer>> joinDs = ds1.join(ds2).where(1).equalTo(1).projectSecond(3).projectFirst(2, 1).projectSecond(4, 1).projectFirst(0);
List<Tuple6<String, String, Long, Long, Long, Integer>> result = joinDs.collect();
String expected = "Hallo,Hi,1,1,1,1\n" + "Hallo Welt,Hello,2,2,2,2\n" + "Hallo Welt,Hello world,2,2,2,3\n";
compareResultAsTuples(result, expected);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class CrossITCase method testProjectCrossOnATupleInput1.
@Test
public void testProjectCrossOnATupleInput1() throws Exception {
/*
* project cross on a tuple input 1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple6<String, Long, String, Integer, Long, Long>> crossDs = ds.cross(ds2).projectFirst(2, 1).projectSecond(3).projectFirst(0).projectSecond(4, 1);
List<Tuple6<String, Long, String, Integer, Long, Long>> result = crossDs.collect();
String expected = "Hi,1,Hallo,1,1,1\n" + "Hi,1,Hallo Welt,1,2,2\n" + "Hi,1,Hallo Welt wie,1,1,3\n" + "Hello,2,Hallo,2,1,1\n" + "Hello,2,Hallo Welt,2,2,2\n" + "Hello,2,Hallo Welt wie,2,1,3\n" + "Hello world,2,Hallo,3,1,1\n" + "Hello world,2,Hallo Welt,3,2,2\n" + "Hello world,2,Hallo Welt wie,3,1,3\n";
compareResultAsTuples(result, expected);
}
Aggregations