use of org.apache.flink.runtime.clusterframework.messages.RemoveResource in project flink by apache.
the class ResourceManagerTest method testResourceRemoval.
@Test
public void testResourceRemoval() {
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();
// remove unknown resource
resourceManager.tell(new RemoveResource(resourceID), fakeJobManager);
// 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());
assertTrue(reply.resources.contains(resourceID));
// remove resource
resourceManager.tell(new RemoveResource(resourceID), fakeJobManager);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(0, reply.resources.size());
}
};
}
};
}
use of org.apache.flink.runtime.clusterframework.messages.RemoveResource in project flink by apache.
the class FlinkResourceManager method handleMessage.
/**
*
* This method receives the actor messages after they have been filtered for
* a match with the leader session.
*
* @param message The incoming actor message.
*/
@Override
protected void handleMessage(Object message) {
try {
if (message instanceof CheckAndAllocateContainers) {
checkWorkersPool();
} else if (message instanceof SetWorkerPoolSize) {
SetWorkerPoolSize msg = (SetWorkerPoolSize) message;
adjustDesignatedNumberOfWorkers(msg.numberOfWorkers());
} else if (message instanceof RemoveResource) {
RemoveResource msg = (RemoveResource) message;
removeRegisteredResource(msg.resourceId());
} else if (message instanceof NotifyResourceStarted) {
NotifyResourceStarted msg = (NotifyResourceStarted) message;
handleResourceStarted(sender(), msg.getResourceID());
} else if (message instanceof NewLeaderAvailable) {
NewLeaderAvailable msg = (NewLeaderAvailable) message;
newJobManagerLeaderAvailable(msg.leaderAddress(), msg.leaderSessionId());
} else if (message instanceof TriggerRegistrationAtJobManager) {
TriggerRegistrationAtJobManager msg = (TriggerRegistrationAtJobManager) message;
triggerConnectingToJobManager(msg.jobManagerAddress());
} else if (message instanceof RegisterResourceManagerSuccessful) {
RegisterResourceManagerSuccessful msg = (RegisterResourceManagerSuccessful) message;
jobManagerLeaderConnected(msg.jobManager(), msg.currentlyRegisteredTaskManagers());
} else if (message instanceof StopCluster) {
StopCluster msg = (StopCluster) message;
shutdownCluster(msg.finalStatus(), msg.message());
sender().tell(decorateMessage(StopClusterSuccessful.getInstance()), ActorRef.noSender());
} else if (message instanceof RegisterInfoMessageListener) {
if (jobManager != null) {
infoMessageListeners.add(sender());
sender().tell(decorateMessage(RegisterInfoMessageListenerSuccessful.get()), // answer as the JobManager
jobManager);
}
} else if (message instanceof UnRegisterInfoMessageListener) {
infoMessageListeners.remove(sender());
} else if (message instanceof FatalErrorOccurred) {
FatalErrorOccurred fatalErrorOccurred = (FatalErrorOccurred) message;
fatalError(fatalErrorOccurred.message(), fatalErrorOccurred.error());
} else // --- unknown messages
{
LOG.error("Discarding unknown message: {}", message);
}
} catch (Throwable t) {
// fatal error, needs master recovery
fatalError("Error processing actor message", t);
}
}
Aggregations