Search in sources :

Example 1 with RestClusterClient

use of org.apache.flink.client.program.rest.RestClusterClient in project flink by apache.

the class DistributedCacheDfsTest method testSubmittingJobViaRestClusterClient.

/**
 * All the Flink Standalone, Yarn, Kubernetes sessions are using {@link
 * RestClusterClient#submitJob(JobGraph)} to submit a job to an existing session. This test will
 * cover this cases.
 */
@Test(timeout = 30000)
public void testSubmittingJobViaRestClusterClient() throws Exception {
    RestClusterClient<String> restClusterClient = new RestClusterClient<>(MINI_CLUSTER_RESOURCE.getClientConfiguration(), "testSubmittingJobViaRestClusterClient");
    final JobGraph jobGraph = createJobWithRegisteredCachedFiles().getStreamGraph().getJobGraph();
    final JobResult jobResult = restClusterClient.submitJob(jobGraph).thenCompose(restClusterClient::requestJobResult).get();
    final String messageInCaseOfFailure = jobResult.getSerializedThrowable().isPresent() ? jobResult.getSerializedThrowable().get().getFullStringifiedStackTrace() : "Job failed.";
    assertTrue(messageInCaseOfFailure, jobResult.isSuccess());
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobResult(org.apache.flink.runtime.jobmaster.JobResult) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) Test(org.junit.Test)

Example 2 with RestClusterClient

use of org.apache.flink.client.program.rest.RestClusterClient in project flink by apache.

the class FlinkContainers method createClusterClient.

// ----------------------------- Helper functions --------------------------------
private RestClusterClient<StandaloneClusterId> createClusterClient() throws Exception {
    checkState(jobManager.isRunning(), "JobManager should be running for creating a REST client");
    // Close potentially existing REST cluster client
    if (restClusterClient != null) {
        restClusterClient.close();
    }
    final Configuration clientConfiguration = new Configuration();
    clientConfiguration.set(RestOptions.ADDRESS, getJobManagerHost());
    clientConfiguration.set(RestOptions.PORT, jobManager.getMappedPort(conf.get(RestOptions.PORT)));
    return new RestClusterClient<>(clientConfiguration, StandaloneClusterId.getInstance());
}
Also used : Configuration(org.apache.flink.configuration.Configuration) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient)

Example 3 with RestClusterClient

use of org.apache.flink.client.program.rest.RestClusterClient in project flink by apache.

the class BigUserProgramJobSubmitITCase method bigDataInMap.

/**
 * Use a map function that references a 100MB byte array.
 */
@Test
public void bigDataInMap() throws Exception {
    // 16 MB
    final byte[] data = new byte[16 * 1024 * 1024];
    // use random data so that Java does not optimise it away
    rnd.nextBytes(data);
    data[1] = 0;
    data[3] = 0;
    data[5] = 0;
    CollectingSink resultSink = new CollectingSink();
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(1);
    DataStream<Integer> src = env.fromElements(1, 3, 5);
    src.map(new MapFunction<Integer, String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String map(Integer value) throws Exception {
            return "x " + value + " " + data[value];
        }
    }).addSink(resultSink);
    JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
    final RestClusterClient<StandaloneClusterId> restClusterClient = new RestClusterClient<>(MINI_CLUSTER_RESOURCE.getClientConfiguration(), StandaloneClusterId.getInstance());
    try {
        submitJobAndWaitForResult(restClusterClient, jobGraph, getClass().getClassLoader());
        List<String> expected = Arrays.asList("x 1 0", "x 3 0", "x 5 0");
        List<String> result = CollectingSink.result;
        Collections.sort(expected);
        Collections.sort(result);
        assertEquals(expected, result);
    } finally {
        restClusterClient.close();
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) MapFunction(org.apache.flink.api.common.functions.MapFunction) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) StandaloneClusterId(org.apache.flink.client.deployment.StandaloneClusterId) Test(org.junit.Test)

Example 4 with RestClusterClient

use of org.apache.flink.client.program.rest.RestClusterClient in project flink by apache.

the class YARNHighAvailabilityITCase method deploySessionCluster.

private RestClusterClient<ApplicationId> deploySessionCluster(YarnClusterDescriptor yarnClusterDescriptor) throws ClusterDeploymentException {
    final int masterMemory = yarnClusterDescriptor.getFlinkConfiguration().get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes();
    final int taskManagerMemory = 1024;
    final ClusterClient<ApplicationId> yarnClusterClient = yarnClusterDescriptor.deploySessionCluster(new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(masterMemory).setTaskManagerMemoryMB(taskManagerMemory).setSlotsPerTaskManager(1).createClusterSpecification()).getClusterClient();
    assertThat(yarnClusterClient, is(instanceOf(RestClusterClient.class)));
    return (RestClusterClient<ApplicationId>) yarnClusterClient;
}
Also used : ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) YarnSessionClusterEntrypoint(org.apache.flink.yarn.entrypoint.YarnSessionClusterEntrypoint)

Aggregations

RestClusterClient (org.apache.flink.client.program.rest.RestClusterClient)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 Test (org.junit.Test)2 MapFunction (org.apache.flink.api.common.functions.MapFunction)1 StandaloneClusterId (org.apache.flink.client.deployment.StandaloneClusterId)1 Configuration (org.apache.flink.configuration.Configuration)1 JobResult (org.apache.flink.runtime.jobmaster.JobResult)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 YarnSessionClusterEntrypoint (org.apache.flink.yarn.entrypoint.YarnSessionClusterEntrypoint)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1