use of org.apache.flink.runtime.taskmanager.TaskManagerLocation in project flink by apache.
the class ResourceManagerITCase method testResourceManagerReconciliation.
/**
* Tests whether the resource manager connects and reconciles existing task managers.
*/
@Test
public void testResourceManagerReconciliation() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
ActorGateway jobManager = TestingUtils.createJobManager(system, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), config, "ReconciliationTest");
ActorGateway me = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
// !! no resource manager started !!
ResourceID resourceID = ResourceID.generate();
TaskManagerLocation location = mock(TaskManagerLocation.class);
when(location.getResourceID()).thenReturn(resourceID);
HardwareDescription resourceProfile = HardwareDescription.extractFromSystem(1_000_000);
jobManager.tell(new RegistrationMessages.RegisterTaskManager(resourceID, location, resourceProfile, 1), me);
expectMsgClass(RegistrationMessages.AcknowledgeRegistration.class);
// now start the resource manager
ActorGateway resourceManager = TestingUtils.createResourceManager(system, jobManager.actor(), config);
// register at testing job manager to receive a message once a resource manager registers
resourceManager.tell(new TestingResourceManager.NotifyWhenResourceManagerConnected(), me);
// Wait for resource manager
expectMsgEquals(Acknowledge.get());
// check if we registered the task manager resource
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), me);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
assertTrue(reply.resources.contains(resourceID));
}
};
}
};
}
use of org.apache.flink.runtime.taskmanager.TaskManagerLocation in project flink by apache.
the class SlotPoolTest method createAllocatedSlot.
static AllocatedSlot createAllocatedSlot(final ResourceID resourceId, final AllocationID allocationId, final JobID jobId, final ResourceProfile resourceProfile) {
TaskManagerLocation mockTaskManagerLocation = mock(TaskManagerLocation.class);
when(mockTaskManagerLocation.getResourceID()).thenReturn(resourceId);
TaskManagerGateway mockTaskManagerGateway = mock(TaskManagerGateway.class);
return new AllocatedSlot(allocationId, jobId, mockTaskManagerLocation, 0, resourceProfile, mockTaskManagerGateway);
}
use of org.apache.flink.runtime.taskmanager.TaskManagerLocation in project flink by apache.
the class InstanceManagerTest method testRegisteringAlreadyRegistered.
@Test
public void testRegisteringAlreadyRegistered() {
try {
InstanceManager cm = new InstanceManager();
final int dataPort = 20000;
ResourceID resID1 = ResourceID.generate();
ResourceID resID2 = ResourceID.generate();
HardwareDescription resources = HardwareDescription.extractFromSystem(4096);
InetAddress address = InetAddress.getByName("127.0.0.1");
TaskManagerLocation ici = new TaskManagerLocation(resID1, address, dataPort);
JavaTestKit probe = new JavaTestKit(system);
cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe.getRef(), leaderSessionID)), ici, resources, 1);
assertEquals(1, cm.getNumberOfRegisteredTaskManagers());
assertEquals(1, cm.getTotalNumberOfSlots());
try {
cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe.getRef(), leaderSessionID)), ici, resources, 1);
} catch (Exception e) {
// good
}
// check for correct number of registered instances
assertEquals(1, cm.getNumberOfRegisteredTaskManagers());
assertEquals(1, cm.getTotalNumberOfSlots());
cm.shutdown();
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
Assert.fail("Test erroneous: " + e.getMessage());
}
}
use of org.apache.flink.runtime.taskmanager.TaskManagerLocation in project flink by apache.
the class InstanceTest method testCancelAllSlots.
@Test
public void testCancelAllSlots() {
try {
ResourceID resourceID = ResourceID.generate();
HardwareDescription hardwareDescription = new HardwareDescription(4, 2L * 1024 * 1024 * 1024, 1024 * 1024 * 1024, 512 * 1024 * 1024);
InetAddress address = InetAddress.getByName("127.0.0.1");
TaskManagerLocation connection = new TaskManagerLocation(resourceID, address, 10001);
Instance instance = new Instance(new ActorTaskManagerGateway(DummyActorGateway.INSTANCE), connection, new InstanceID(), hardwareDescription, 3);
assertEquals(3, instance.getNumberOfAvailableSlots());
SimpleSlot slot1 = instance.allocateSimpleSlot(new JobID());
SimpleSlot slot2 = instance.allocateSimpleSlot(new JobID());
SimpleSlot slot3 = instance.allocateSimpleSlot(new JobID());
instance.cancelAndReleaseAllSlots();
assertEquals(3, instance.getNumberOfAvailableSlots());
assertTrue(slot1.isCanceled());
assertTrue(slot2.isCanceled());
assertTrue(slot3.isCanceled());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.taskmanager.TaskManagerLocation in project flink by apache.
the class SimpleSlotTest method getSlot.
public static SimpleSlot getSlot() throws Exception {
ResourceID resourceID = ResourceID.generate();
HardwareDescription hardwareDescription = new HardwareDescription(4, 2L * 1024 * 1024 * 1024, 1024 * 1024 * 1024, 512 * 1024 * 1024);
InetAddress address = InetAddress.getByName("127.0.0.1");
TaskManagerLocation connection = new TaskManagerLocation(resourceID, address, 10001);
Instance instance = new Instance(new ActorTaskManagerGateway(DummyActorGateway.INSTANCE), connection, new InstanceID(), hardwareDescription, 1);
return instance.allocateSimpleSlot(new JobID());
}
Aggregations