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());
}
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());
}
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();
}
}
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;
}
Aggregations