Search in sources :

Example 1 with InfoMessage

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;
}
Also used : Timeout(akka.util.Timeout) InfoMessage(org.apache.flink.runtime.clusterframework.messages.InfoMessage) ArrayList(java.util.ArrayList) Option(scala.Option) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException)

Aggregations

Timeout (akka.util.Timeout)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)1 InfoMessage (org.apache.flink.runtime.clusterframework.messages.InfoMessage)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 Option (scala.Option)1