Search in sources :

Example 1 with ResourceRemoved

use of org.apache.flink.runtime.clusterframework.messages.ResourceRemoved 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());
                }
            };
        }
    };
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TestingResourceManager(org.apache.flink.runtime.testutils.TestingResourceManager) RegisterResourceManagerSuccessful(org.apache.flink.runtime.clusterframework.messages.RegisterResourceManagerSuccessful) NotifyResourceStarted(org.apache.flink.runtime.clusterframework.messages.NotifyResourceStarted) ResourceRemoved(org.apache.flink.runtime.clusterframework.messages.ResourceRemoved) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Aggregations

JavaTestKit (akka.testkit.JavaTestKit)1 NotifyResourceStarted (org.apache.flink.runtime.clusterframework.messages.NotifyResourceStarted)1 RegisterResourceManagerSuccessful (org.apache.flink.runtime.clusterframework.messages.RegisterResourceManagerSuccessful)1 ResourceRemoved (org.apache.flink.runtime.clusterframework.messages.ResourceRemoved)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 TestingResourceManager (org.apache.flink.runtime.testutils.TestingResourceManager)1 Test (org.junit.Test)1