use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class SlotSharingGroupAssignment method removeSlotFromAllEntries.
private static void removeSlotFromAllEntries(Map<AbstractID, Map<ResourceID, List<SharedSlot>>> availableSlots, SharedSlot slot) {
final ResourceID taskManagerId = slot.getTaskManagerID();
for (Map.Entry<AbstractID, Map<ResourceID, List<SharedSlot>>> entry : availableSlots.entrySet()) {
Map<ResourceID, List<SharedSlot>> map = entry.getValue();
List<SharedSlot> list = map.get(taskManagerId);
if (list != null) {
list.remove(slot);
if (list.isEmpty()) {
map.remove(taskManagerId);
}
}
}
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID 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.clusterframework.types.ResourceID in project flink by apache.
the class ResourceManagerTest method testResourceFailureNotification.
/**
* Tests notification of JobManager about a failed resource.
*/
@Test
public void testResourceFailureNotification() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), config);
// register with JM
expectMsgClass(RegisterResourceManager.class);
resourceManager.tell(new RegisterResourceManagerSuccessful(fakeJobManager.actor(), Collections.<ResourceID>emptyList()), fakeJobManager);
ResourceID resourceID1 = ResourceID.generate();
ResourceID resourceID2 = ResourceID.generate();
// Send task manager registration
resourceManager.tell(new NotifyResourceStarted(resourceID1), fakeJobManager);
expectMsgClass(Acknowledge.class);
// Send task manager registration
resourceManager.tell(new NotifyResourceStarted(resourceID2), fakeJobManager);
expectMsgClass(Acknowledge.class);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(2, reply.resources.size());
assertTrue(reply.resources.contains(resourceID1));
assertTrue(reply.resources.contains(resourceID2));
// fail resources
resourceManager.tell(new TestingResourceManager.FailResource(resourceID1), fakeJobManager);
resourceManager.tell(new TestingResourceManager.FailResource(resourceID2), fakeJobManager);
ResourceRemoved answer = expectMsgClass(ResourceRemoved.class);
ResourceRemoved answer2 = expectMsgClass(ResourceRemoved.class);
assertEquals(resourceID1, answer.resourceId());
assertEquals(resourceID2, answer2.resourceId());
}
};
}
};
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class ResourceManagerTest method testTaskManagerRegistration.
/**
* Tests the registration and accounting of resources at the ResourceManager.
*/
@Test
public void testTaskManagerRegistration() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), config);
// register with JM
expectMsgClass(RegisterResourceManager.class);
resourceManager.tell(new RegisterResourceManagerSuccessful(fakeJobManager.actor(), Collections.<ResourceID>emptyList()), fakeJobManager);
ResourceID resourceID = ResourceID.generate();
// Send task manager registration
resourceManager.tell(new NotifyResourceStarted(resourceID), fakeJobManager);
expectMsgClass(Acknowledge.class);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
// Send task manager registration again
resourceManager.tell(new NotifyResourceStarted(resourceID), fakeJobManager);
expectMsgClass(Acknowledge.class);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
// Send invalid null resource id to throw an exception during resource registration
resourceManager.tell(new NotifyResourceStarted(null), fakeJobManager);
expectMsgClass(Acknowledge.class);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
}
};
}
};
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class SlotPoolTest method testReleaseResource.
@Test
public void testReleaseResource() throws Exception {
ResourceID resourceID = new ResourceID("resource");
slotPool.registerTaskManager(resourceID);
Future<SimpleSlot> future1 = slotPool.allocateSlot(mock(ScheduledUnit.class), DEFAULT_TESTING_PROFILE, null);
ArgumentCaptor<SlotRequest> slotRequestArgumentCaptor = ArgumentCaptor.forClass(SlotRequest.class);
verify(resourceManagerGateway).requestSlot(any(UUID.class), any(UUID.class), slotRequestArgumentCaptor.capture(), any(Time.class));
final SlotRequest slotRequest = slotRequestArgumentCaptor.getValue();
Future<SimpleSlot> future2 = slotPool.allocateSlot(mock(ScheduledUnit.class), DEFAULT_TESTING_PROFILE, null);
AllocatedSlot allocatedSlot = createAllocatedSlot(resourceID, slotRequest.getAllocationId(), jobId, DEFAULT_TESTING_PROFILE);
assertTrue(slotPool.offerSlot(allocatedSlot));
SimpleSlot slot1 = future1.get(1, TimeUnit.SECONDS);
assertTrue(future1.isDone());
assertFalse(future2.isDone());
slotPool.releaseTaskManager(resourceID);
assertTrue(slot1.isReleased());
// slot released and not usable, second allocation still not fulfilled
Thread.sleep(10);
assertFalse(future2.isDone());
}
Aggregations