Search in sources :

Example 1 with ProgramInvocationException

use of org.apache.flink.client.program.ProgramInvocationException in project flink by apache.

the class ScalaShellRemoteStreamEnvironment method executeRemotely.

/**
	 * Executes the remote job.
	 *
	 * @param streamGraph
	 *            Stream Graph to execute
	 * @param jarFiles
	 * 			  List of jar file URLs to ship to the cluster
	 * @return The result of the job execution, containing elapsed time and accumulators.
	 */
@Override
protected JobExecutionResult executeRemotely(StreamGraph streamGraph, List<URL> jarFiles) throws ProgramInvocationException {
    URL jarUrl;
    try {
        jarUrl = flinkILoop.writeFilesToDisk().getAbsoluteFile().toURI().toURL();
    } catch (MalformedURLException e) {
        throw new ProgramInvocationException("Could not write the user code classes to disk.", e);
    }
    List<URL> allJarFiles = new ArrayList<>(jarFiles.size() + 1);
    allJarFiles.addAll(jarFiles);
    allJarFiles.add(jarUrl);
    return super.executeRemotely(streamGraph, allJarFiles);
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) URL(java.net.URL)

Example 2 with ProgramInvocationException

use of org.apache.flink.client.program.ProgramInvocationException in project flink by apache.

the class RemoteStreamEnvironment method executeRemotely.

/**
	 * Executes the remote job.
	 * 
	 * @param streamGraph
	 *            Stream Graph to execute
	 * @param jarFiles
	 * 			  List of jar file URLs to ship to the cluster
	 * @return The result of the job execution, containing elapsed time and accumulators.
	 */
protected JobExecutionResult executeRemotely(StreamGraph streamGraph, List<URL> jarFiles) throws ProgramInvocationException {
    if (LOG.isInfoEnabled()) {
        LOG.info("Running remotely at {}:{}", host, port);
    }
    ClassLoader usercodeClassLoader = JobWithJars.buildUserCodeClassLoader(jarFiles, globalClasspaths, getClass().getClassLoader());
    Configuration configuration = new Configuration();
    configuration.addAll(this.clientConfiguration);
    configuration.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, host);
    configuration.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, port);
    ClusterClient client;
    try {
        client = new StandaloneClusterClient(configuration);
        client.setPrintStatusDuringExecution(getConfig().isSysoutLoggingEnabled());
    } catch (Exception e) {
        throw new ProgramInvocationException("Cannot establish connection to JobManager: " + e.getMessage(), e);
    }
    try {
        return client.run(streamGraph, jarFiles, globalClasspaths, usercodeClassLoader).getJobExecutionResult();
    } catch (ProgramInvocationException e) {
        throw e;
    } catch (Exception e) {
        String term = e.getMessage() == null ? "." : (": " + e.getMessage());
        throw new ProgramInvocationException("The program execution failed" + term, e);
    } finally {
        client.shutdown();
    }
}
Also used : StandaloneClusterClient(org.apache.flink.client.program.StandaloneClusterClient) ClusterClient(org.apache.flink.client.program.ClusterClient) Configuration(org.apache.flink.configuration.Configuration) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) StandaloneClusterClient(org.apache.flink.client.program.StandaloneClusterClient) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException)

Example 3 with ProgramInvocationException

use of org.apache.flink.client.program.ProgramInvocationException in project flink by apache.

the class CustomSerializationITCase method testIncorrectSerializer4.

@Test
public void testIncorrectSerializer4() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("localhost", cluster.getLeaderRPCPort());
        env.setParallelism(PARLLELISM);
        env.getConfig().disableSysoutLogging();
        env.generateSequence(1, 10 * PARLLELISM).map(new MapFunction<Long, ConsumesTooLittleSpanning>() {

            @Override
            public ConsumesTooLittleSpanning map(Long value) throws Exception {
                return new ConsumesTooLittleSpanning();
            }
        }).rebalance().output(new DiscardingOutputFormat<ConsumesTooLittleSpanning>());
        env.execute();
    } catch (ProgramInvocationException e) {
        Throwable rootCause = e.getCause().getCause();
        assertTrue(rootCause instanceof IOException);
        assertTrue(rootCause.getMessage().contains("broken serialization"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with ProgramInvocationException

use of org.apache.flink.client.program.ProgramInvocationException in project flink by apache.

the class CustomSerializationITCase method testIncorrectSerializer1.

@Test
public void testIncorrectSerializer1() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("localhost", cluster.getLeaderRPCPort());
        env.setParallelism(PARLLELISM);
        env.getConfig().disableSysoutLogging();
        env.generateSequence(1, 10 * PARLLELISM).map(new MapFunction<Long, ConsumesTooMuch>() {

            @Override
            public ConsumesTooMuch map(Long value) throws Exception {
                return new ConsumesTooMuch();
            }
        }).rebalance().output(new DiscardingOutputFormat<ConsumesTooMuch>());
        env.execute();
    } catch (ProgramInvocationException e) {
        Throwable rootCause = e.getCause().getCause();
        assertTrue(rootCause instanceof IOException);
        assertTrue(rootCause.getMessage().contains("broken serialization"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with ProgramInvocationException

use of org.apache.flink.client.program.ProgramInvocationException in project flink by apache.

the class CustomSerializationITCase method testIncorrectSerializer3.

@Test
public void testIncorrectSerializer3() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("localhost", cluster.getLeaderRPCPort());
        env.setParallelism(PARLLELISM);
        env.getConfig().disableSysoutLogging();
        env.generateSequence(1, 10 * PARLLELISM).map(new MapFunction<Long, ConsumesTooLittle>() {

            @Override
            public ConsumesTooLittle map(Long value) throws Exception {
                return new ConsumesTooLittle();
            }
        }).rebalance().output(new DiscardingOutputFormat<ConsumesTooLittle>());
        env.execute();
    } catch (ProgramInvocationException e) {
        Throwable rootCause = e.getCause().getCause();
        assertTrue(rootCause instanceof IOException);
        assertTrue(rootCause.getMessage().contains("broken serialization"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)23 Test (org.junit.Test)13 IOException (java.io.IOException)8 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)8 Configuration (org.apache.flink.configuration.Configuration)7 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)5 File (java.io.File)4 URL (java.net.URL)4 Properties (java.util.Properties)3 PackagedProgram (org.apache.flink.client.program.PackagedProgram)3 Path (org.apache.flink.core.fs.Path)3 CompilerException (org.apache.flink.optimizer.CompilerException)3 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)3 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)3 FileNotFoundException (java.io.FileNotFoundException)2 StringWriter (java.io.StringWriter)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 JobSubmissionResult (org.apache.flink.api.common.JobSubmissionResult)2 ClusterClient (org.apache.flink.client.program.ClusterClient)2