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);
}
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));
}
};
}
};
}
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);
}
Aggregations