use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class ResourceManagerTest method testTriggerReconnect.
@Test
public void testTriggerReconnect() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
// set a long timeout for lookups such that the test fails in case of timeouts
Configuration shortTimeoutConfig = config.clone();
shortTimeoutConfig.setString(ConfigConstants.AKKA_LOOKUP_TIMEOUT, "99999 s");
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), shortTimeoutConfig);
// wait for registration message
RegisterResourceManager msg = expectMsgClass(RegisterResourceManager.class);
// all went well
resourceManager.tell(new RegisterResourceManagerSuccessful(fakeJobManager.actor(), Collections.<ResourceID>emptyList()), fakeJobManager);
// force a reconnect
resourceManager.tell(new TriggerRegistrationAtJobManager(fakeJobManager.actor()), fakeJobManager);
// new registration attempt should come in
expectMsgClass(RegisterResourceManager.class);
}
};
}
};
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class InputChannelDeploymentDescriptorTest method testUnknownChannelWithoutLazyDeploymentThrows.
@Test
public void testUnknownChannelWithoutLazyDeploymentThrows() throws Exception {
ResourceID consumerResourceId = ResourceID.generate();
ExecutionVertex consumer = mock(ExecutionVertex.class);
SimpleSlot consumerSlot = mockSlot(consumerResourceId);
// Unknown partition
// no assigned resource
ExecutionVertex unknownProducer = mockExecutionVertex(ExecutionState.CREATED, null);
IntermediateResultPartition unknownPartition = mockPartition(unknownProducer);
ResultPartitionID unknownPartitionId = new ResultPartitionID(unknownPartition.getPartitionId(), unknownProducer.getCurrentExecutionAttempt().getAttemptId());
ExecutionEdge unknownEdge = new ExecutionEdge(unknownPartition, consumer, 2);
// This should work if lazy deployment is allowed
boolean allowLazyDeployment = true;
InputChannelDeploymentDescriptor[] desc = InputChannelDeploymentDescriptor.fromEdges(new ExecutionEdge[] { unknownEdge }, consumerSlot, allowLazyDeployment);
assertEquals(1, desc.length);
assertEquals(unknownPartitionId, desc[0].getConsumedPartitionId());
assertTrue(desc[0].getConsumedPartitionLocation().isUnknown());
assertNull(desc[0].getConsumedPartitionLocation().getConnectionId());
try {
// Fail if lazy deployment is *not* allowed
allowLazyDeployment = false;
InputChannelDeploymentDescriptor.fromEdges(new ExecutionEdge[] { unknownEdge }, consumerSlot, allowLazyDeployment);
fail("Did not throw expected ExecutionGraphException");
} catch (ExecutionGraphException ignored) {
}
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class ResourceManager method notifySlotAvailable.
/**
* Notification from a TaskExecutor that a slot has become available
* @param resourceManagerLeaderId TaskExecutor's resource manager leader id
* @param instanceID TaskExecutor's instance id
* @param slotId The slot id of the available slot
* @return SlotAvailableReply
*/
@RpcMethod
public void notifySlotAvailable(final UUID resourceManagerLeaderId, final InstanceID instanceID, final SlotID slotId) {
if (resourceManagerLeaderId.equals(leaderSessionId)) {
final ResourceID resourceId = slotId.getResourceID();
WorkerRegistration<WorkerType> registration = taskExecutors.get(resourceId);
if (registration != null) {
InstanceID registrationId = registration.getInstanceID();
if (registrationId.equals(instanceID)) {
slotManager.notifySlotAvailable(resourceId, slotId);
} else {
log.debug("Invalid registration id for slot available message. This indicates an" + " outdated request.");
}
} else {
log.debug("Could not find registration for resource id {}. Discarding the slot available" + "message {}.", resourceId, slotId);
}
} else {
log.debug("Discarding notify slot available message for slot {}, because the " + "leader id {} did not match the expected leader id {}.", slotId, resourceManagerLeaderId, leaderSessionId);
}
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class SlotManager method addFreeSlot.
/**
* Add free slots directly to the free pool, this will not trigger pending requests allocation
*
* @param slot The resource slot
*/
@VisibleForTesting
void addFreeSlot(final ResourceSlot slot) {
final ResourceID resourceId = slot.getResourceID();
final SlotID slotId = slot.getSlotId();
if (!registeredSlots.containsKey(resourceId)) {
registeredSlots.put(resourceId, new HashMap<SlotID, ResourceSlot>());
}
registeredSlots.get(resourceId).put(slot.getSlotId(), slot);
freeSlots.put(slotId, slot);
}
use of org.apache.flink.runtime.clusterframework.types.ResourceID in project flink by apache.
the class SlotManager method registerNewSlot.
/**
* Registers a new slot with the SlotManager.
*
* @param slot The ResourceSlot which will be registered
*/
private void registerNewSlot(final ResourceSlot slot) {
final SlotID slotId = slot.getSlotId();
final ResourceID resourceId = slotId.getResourceID();
if (!registeredSlots.containsKey(resourceId)) {
registeredSlots.put(resourceId, new HashMap<SlotID, ResourceSlot>());
}
registeredSlots.get(resourceId).put(slotId, slot);
}
Aggregations