use of org.apache.flink.runtime.clusterframework.messages.InfoMessage in project flink by apache.
the class YarnClusterClient method getNewMessages.
@Override
public List<String> getNewMessages() {
if (hasBeenShutdown()) {
throw new RuntimeException("The YarnClusterClient has already been stopped");
}
if (!isConnected) {
throw new IllegalStateException("The cluster has been connected to the ApplicationMaster.");
}
List<String> ret = new ArrayList<String>();
// get messages from ApplicationClient (locally)
while (true) {
Object result;
try {
Future<Object> response = Patterns.ask(applicationClient.get(), YarnMessages.getLocalGetYarnMessage(), new Timeout(akkaDuration));
result = Await.result(response, akkaDuration);
} catch (Exception ioe) {
LOG.warn("Error retrieving the YARN messages locally", ioe);
break;
}
if (!(result instanceof Option)) {
throw new RuntimeException("LocalGetYarnMessage requires a response of type " + "Option. Instead the response is of type " + result.getClass() + ".");
} else {
Option messageOption = (Option) result;
LOG.debug("Received message option {}", messageOption);
if (messageOption.isEmpty()) {
break;
} else {
Object obj = messageOption.get();
if (obj instanceof InfoMessage) {
InfoMessage msg = (InfoMessage) obj;
ret.add("[" + msg.date() + "] " + msg.message());
} else {
LOG.warn("LocalGetYarnMessage returned unexpected type: " + messageOption);
}
}
}
}
return ret;
}
Aggregations