Search in sources :

Example 1 with HardwareDescription

use of org.apache.flink.runtime.instance.HardwareDescription in project flink by apache.

the class ExecutionGraphTestUtils method getInstance.

public static Instance getInstance(final TaskManagerGateway gateway, final int numberOfSlots) 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);
    return new Instance(gateway, connection, new InstanceID(), hardwareDescription, numberOfSlots);
}
Also used : HardwareDescription(org.apache.flink.runtime.instance.HardwareDescription) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) Instance(org.apache.flink.runtime.instance.Instance) InstanceID(org.apache.flink.runtime.instance.InstanceID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) InetAddress(java.net.InetAddress)

Example 2 with HardwareDescription

use of org.apache.flink.runtime.instance.HardwareDescription 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));
                }
            };
        }
    };
}
Also used : RegistrationMessages(org.apache.flink.runtime.messages.RegistrationMessages) HardwareDescription(org.apache.flink.runtime.instance.HardwareDescription) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) TestingResourceManager(org.apache.flink.runtime.testutils.TestingResourceManager) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 3 with HardwareDescription

use of org.apache.flink.runtime.instance.HardwareDescription in project flink by apache.

the class SchedulerTestUtils method getRandomInstance.

// --------------------------------------------------------------------------------------------
public static Instance getRandomInstance(int numSlots) {
    if (numSlots <= 0) {
        throw new IllegalArgumentException();
    }
    final ResourceID resourceID = ResourceID.generate();
    final InetAddress address;
    try {
        address = InetAddress.getByName("127.0.0.1");
    } catch (UnknownHostException e) {
        throw new RuntimeException("Test could not create IP address for localhost loopback.");
    }
    int dataPort = port.getAndIncrement();
    TaskManagerLocation ci = new TaskManagerLocation(resourceID, address, dataPort);
    final long GB = 1024L * 1024 * 1024;
    HardwareDescription resources = new HardwareDescription(4, 4 * GB, 3 * GB, 2 * GB);
    return new Instance(new ActorTaskManagerGateway(DummyActorGateway.INSTANCE), ci, new InstanceID(), resources, numSlots);
}
Also used : HardwareDescription(org.apache.flink.runtime.instance.HardwareDescription) UnknownHostException(java.net.UnknownHostException) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) Instance(org.apache.flink.runtime.instance.Instance) InstanceID(org.apache.flink.runtime.instance.InstanceID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) InetAddress(java.net.InetAddress) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)

Aggregations

ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 HardwareDescription (org.apache.flink.runtime.instance.HardwareDescription)3 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)3 InetAddress (java.net.InetAddress)2 Instance (org.apache.flink.runtime.instance.Instance)2 InstanceID (org.apache.flink.runtime.instance.InstanceID)2 JavaTestKit (akka.testkit.JavaTestKit)1 UnknownHostException (java.net.UnknownHostException)1 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)1 ActorTaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)1 RegistrationMessages (org.apache.flink.runtime.messages.RegistrationMessages)1 TestingResourceManager (org.apache.flink.runtime.testutils.TestingResourceManager)1 Test (org.junit.Test)1